public SocketAction GetRPCs() { Dictionary <string, object> parameters = new Dictionary <string, object>(); SocketAction action = this.action("getRPCs", parameters); return(action); }
protected SocketAction action(string actionName, Dictionary <string, object> parameters) { string payload = DictionarySerializer.ToJSON(parameters); SocketAction action = new SocketAction(this, actionName, payload); return(action); }
public void GetAllUserConversations(string uid) { var content = new SocketAction { Route = "conversation.get.all", Payload = new { uid } }; Emit(ActionRoute, content); }
void handleError(bool needClose, SocketAction action, string msg) { Log.D(string.Format("{0},{1},{2}", needClose, action, msg), Log.Tag.Net); if (needClose) { closeSocket(); } mSocketState = SocketState.Error; }
public void GetAllUsers() { var content = new SocketAction { Route = "user.get.all", Payload = new { } }; Emit(ActionRoute, content); }
public SocketAction JoinGame(string playerName) { Dictionary <string, object> parameters = new Dictionary <string, object>(); parameters["playerName"] = playerName; SocketAction action = this.rpcAction(RPCName.JoinGame, parameters); return(action); }
public static void AddVirtualPlayer(string gameID) { var content = new SocketAction { Route = "game.patch.addVirtual", Payload = new { _id = gameID } }; WebSocket.Instance.Emit("action", content); }
public void JoinGame(string uid, string gid) { var content = new SocketAction { Route = "game.patch.join", Payload = new { _id = gid, uid } }; Emit(ActionRoute, content); }
public void GetActiveGames() { var content = new SocketAction { Route = "game.get.active", Payload = new { } }; Emit(ActionRoute, content); }
public void CreateNewGame(string uid) { var content = new SocketAction { Route = "game.post.create", Payload = new { uid } }; Emit(ActionRoute, content); }
public SocketAction Move(int direction) { Dictionary <string, object> parameters = new Dictionary <string, object>(); parameters["direction"] = direction; SocketAction action = this.rpcAction(RPCName.Move, parameters); return(action); }
/* * Send event to the server */ public void GetAllConversations() { var content = new SocketAction { Route = "conversation.get.search", Payload = new { } }; Emit(ActionRoute, content); }
public void CreateStroke(Path path) { var content = new SocketAction { Route = "canvas.patch.stroke", Payload = path }; Emit(ActionRoute, content); }
public static void LeaveGame(string gid, string uid) { var content = new SocketAction { Route = "game.patch.quit", Payload = new { _id = gid, uid } }; WebSocket.Instance.Emit("action", content); }
public void GetConversationMessages(string cid) { var content = new SocketAction { Route = "message.get.all", Payload = new { cid } }; Emit(ActionRoute, content); }
public void GetAllConnectedUsers() { var content = new SocketAction { Route = "user.get.online", Payload = { } }; Emit(ActionRoute, content); }
public void CreateConversation(string[] uids, string convName) { var content = new SocketAction { Route = "conversation.post.create", Payload = new { uids, convName } }; Emit(ActionRoute, content); }
public void GetConversation(string cid) { var content = new SocketAction { Route = "conversation.get.one", Payload = new { cid } }; Emit(ActionRoute, content); }
public SocketAction JoinRoom(string roomID) { Dictionary <string, object> parameters = new Dictionary <string, object>(); parameters["roomId"] = roomID; SocketAction action = this.action("joinRoom", parameters); return(action); }
public void AddSocket(Socket socket, Action read, Action write, Action error) { SocketAction action = new SocketAction(); action.RWE[0] = read; action.RWE[1] = write; action.RWE[2] = error; _pendingAdd.Add(new object[] { socket, action }); }
void OnComplete(TcpClient client, SocketAction action, string msg) { lock (_lockObj) { SocketEvent se = new SocketEvent() { _action = action, _msg = msg, }; _socketEventList.Add(se); } }
void OnComplete(SocketAsyncEventArgs args, SocketAction action) { try { Completed?.Invoke(args, action); } catch (Exception e) { Debug.LogError($"Server OnComplete() Exception - {e}"); throw; } }
public void AddUserToConversation(string cid, string uid) { var content = new SocketAction { Route = "conversation.patch.addUser", Payload = new { cid, uid } }; Emit(ActionRoute, content); }
protected SocketAction rpcAction(string rpcName, Dictionary <string, object> parameters) { Dictionary <string, object> rpcParameters = new Dictionary <string, object>(); rpcParameters["rpcName"] = rpcName; rpcParameters["parameters"] = parameters; string payload = DictionarySerializer.ToJSON(rpcParameters); SocketAction action = new SocketAction(this, "rpc", payload); return(action); }
public void RefereshUser() { if (isConnected && AppContext.AppContextSingleton.Instance.AppContext?.CurrentConnectedUser != null) { var content = new SocketAction { Route = "user.get.one", Payload = new { uid = AppContext.AppContextSingleton.Instance.AppContext?.CurrentConnectedUser.UID } }; Emit(ActionRoute, content); } }
public void CreateCanvas(List <string> uids) { var content = new SocketAction { Route = "canvas.post.create", Payload = new { uids, } }; Emit(ActionRoute, content); }
public virtual void OnComplete(TcpClient client, SocketAction action, string msg) { if (Completed == null) { Log("AsynSocketClient OnComplete Error - Completed() function not found!"); } Completed?.Invoke(client, action, msg); if (action == SocketAction.Connect) { // 接收数据 ThreadPool.QueueUserWorkItem(x => { //while (!isStopWork) // 原始代码这里写错了。。。这里会导致几秒钟之内内存占用超过10G { try { ReceiveAsync(); Log("AsynsocketClient OnComplete connect - " + msg); //Thread.Sleep(20); } catch (Exception ex) { Stop(); string err = $"AsynsocketClient OnComplete Exception (Connect) - {ex}"; OnComplete(client, SocketAction.Error, err); } } }); } else if (action == SocketAction.Send) { } else if (action == SocketAction.Receive) { } else if (action == SocketAction.Close) { try { Log("Socket closed."); this.Received = null; tcpClient.Close(); } catch (Exception e) { string err = $"AsynSocketClient OnComplete Exception (Close) - {e}"; OnComplete(client, SocketAction.Error, err); } } }
public void InviteUserToConversation(string cid, string uid) { var content = new SocketAction { Route = "conversation.post.invite", Payload = new { cid, uid } }; Emit(ActionRoute, content); }
void OnComplete(SocketAction action, string msg) { switch (action) { case SocketAction.Connect: { UIManager.Instance.SystemTips(msg, PanelSystemTips.MessageType.Success); // 登录到RoomServer PlayerEnter enter = new PlayerEnter(); if (ClientManager.Instance != null) { enter.Account = ClientManager.Instance.Player.Account; enter.TokenId = ClientManager.Instance.Player.TokenId; } else { enter.Account = "Footman3"; enter.TokenId = 123456; //enter.TokenId = 1234561; } CurrentPlayer.Init(enter.Account, enter.TokenId); SendMsg(ROOM.PlayerEnter, enter.ToByteArray()); StartHeartBeat(); // 开始心跳 Log(msg); } break; case SocketAction.Send: break; case SocketAction.Receive: break; case SocketAction.Close: StopHeartBeat(); UIManager.Instance.SystemTips(msg, PanelSystemTips.MessageType.Error); UIManager.Instance.MessageBox("错误", msg, (int)PanelMessageBox.BUTTON.OK, OnClickMessageBox); Debug.LogWarning(msg); break; case SocketAction.Error: UIManager.Instance.SystemTips(msg, PanelSystemTips.MessageType.Error); UIManager.Instance.MessageBox("错误", msg, (int)PanelMessageBox.BUTTON.OK, OnClickMessageBox); Debug.LogWarning(msg); break; } }
public void CreateGameImage(GameImage gameImage) { var content = new SocketAction { Route = "gameImage.post.create", Payload = new { hints = gameImage.Hints, word = gameImage.Word, lang = gameImage.WordLanguage, difficulty = gameImage.Difficulty, canvas = gameImage.Canvas, drawing_mode = gameImage.DrawingMode } }; Emit(ActionRoute, content); }