예제 #1
0
func (wsc *WebsocketController) Logout(ws *websocket.Conn, reqJson ReqJsonRpc) {
	player := myim.FindPlayer(ws)
	if player == nil {
		// 没有这个用户
		return
	}
	player.LogOut()
}
예제 #2
0
func (wsc *WebsocketController) Sendto(ws *websocket.Conn, reqJson ReqJsonRpc) {
	player := myim.FindPlayer(ws)
	if player == nil {
		myim.Sender.Error(ws, "2", "请先登录.....")
		return
	}
	if reqJson.Params["content"] == "" || reqJson.Params["player_id"] == "" {
		myim.Sender.Error(ws, "1", "参数错误~")
		return
	}
	if reqJson.Params["player_id"] == "all" {
		player.SendToPlayers(reqJson.Params["content"])
		return
	}
	player_id, err_strconv_int := strconv.ParseInt(reqJson.Params["player_id"], 10, 64)
	if err_strconv_int != nil {
		myim.Sender.Error(ws, "1", "参数错误~")
		return
	}
	to := myim.FindPlayer(player_id)
	player.SendToPlayer(reqJson.Params["content"], to)
}