IEnumerator Start()
    {
        conn = GetComponent<SocketIOConnection>();
        conn.handler.OnConnect += OnConnect;
        conn.handler.OnEvent += OnEvent;

        while(!conn.Ready)
            yield return new WaitForSeconds(2);
        conn.Emit("boo");
    }
Ejemplo n.º 2
0
    IEnumerator Start()
    {
        conn = GetComponent <SocketIOConnection>();
        conn.handler.OnConnect += OnConnect;
        conn.handler.OnEvent   += OnEvent;

        while (!conn.Ready)
        {
            yield return(new WaitForSeconds(2));
        }
        conn.Emit("boo");
    }
Ejemplo n.º 3
0
    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();
        }
    }
Ejemplo n.º 4
0
 void HandleNewsEvent(SocketIOConnection socket, SocketIOMessage msg)
 {
     Debug.Log("Received Event: " + msg.eventName + "(" + msg.args + ")");
 }
 void Awake()
 {
     _socket  = GetComponent <SocketIOConnection>();
     Instance = this;
 }
Ejemplo n.º 6
0
        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)));
        }
Ejemplo n.º 7
0
 void Awake()
 {
     _socket = GetComponent<SocketIOConnection>();
     Instance = this;
 }