IEnumerator Start() { conn = GetComponent<SocketIOConnection>(); conn.handler.OnConnect += OnConnect; conn.handler.OnEvent += OnEvent; while(!conn.Ready) yield return new WaitForSeconds(2); conn.Emit("boo"); }
IEnumerator Start() { conn = GetComponent <SocketIOConnection>(); conn.handler.OnConnect += OnConnect; conn.handler.OnEvent += OnEvent; while (!conn.Ready) { yield return(new WaitForSeconds(2)); } conn.Emit("boo"); }
public void StartExchange() { receiverFromServer = this.GetComponent <ReceiverFromServer>(); connection = this.GetComponent <SocketIOConnection>(); if (!receiverFromServer) { throw new Exception("There is no ReciverFromServer on the same component"); } if (!connection) { throw new Exception("There is no SocketIOConnection on the same component"); } Debug.Log("Found socketIOConnection component url:" + connection.Url); SubscribeOnSocketIOEvents(); if (connection.IsConnected) { Register(); } }
void HandleNewsEvent(SocketIOConnection socket, SocketIOMessage msg) { Debug.Log("Received Event: " + msg.eventName + "(" + msg.args + ")"); }
void Awake() { _socket = GetComponent <SocketIOConnection>(); Instance = this; }
private void userJoin(SocketIOConnection socket) { GatewayUserModel user = null; socket.On("Gateway.Message", new Action<GatewayMessageModel>((data) => { if (user == null) { Global.Console.Log("no user found: " + data.Stringify()); return; } var channel = user.GameServer; switch (data.Channel) { case "Game": channel = user.GameServer; break; case "Chat": channel = user.ChatServer ?? "ChatServer"; break; } queueManager.SendMessage(user, channel, data.Content); })); socket.On("Gateway.Login", new Action<GatewayLoginMessageModel>((data) => { user = new GatewayUserModel(); user.Socket = socket; user.UserName = data.UserName; user.Gateway = myName; users[data.UserName] = user; queueManager.SendMessage(user, "GameServer", new PlayerJoinMessage()); })); socket.On("disconnect", new Action<string>((data) => users.Remove(user.UserName))); }
void Awake() { _socket = GetComponent<SocketIOConnection>(); Instance = this; }