예제 #1
0
 // Use this for initialization
 void Start()
 {
     socket.On("match:joined", (SocketIOEvent e) =>
     {
         Debug.Log("[SocketIO] LFM Request successfull.");
         StartCoroutine(InitializeMatch(e.data));
         socket.On("endMatch", (SocketIOEvent ev) =>
         {
             if (SceneManager.GetActiveScene().buildIndex != 1)
             {
                 socket.Off("spell:result", (SocketIOEvent evnt) =>
                 {
                     SpellResult(evnt.data);
                 });
                 socket.Off("spell:pending", (SocketIOEvent evnt) =>
                 {
                     SpellPending(evnt.data);
                 }); socket.Off("spell:blocked", (SocketIOEvent evnt) =>
                 {
                     SpellBlocked(evnt.data);
                 });
                 SceneManager.LoadScene(1);
             }
         });
     });
 }
예제 #2
0
        public override void OnEndState()
        {
            base.OnEndState();

            _socket.Off(LobbyEvents.SERVER_UPDATE, OnServerUpdate);
            _socket.Off(LobbyEvents.GAME_UPDATE, OnGameUpdate);
            _socket.Off(LobbyEvents.GAME_STARTED, OnGameStarted);
        }
예제 #3
0
    private void Disconnect()
    {
        socket.Off("error", ErrorCallback);
        socket.Off("SUCCESS_CONNECT", OnSuccessConnect);
        socket.Off("INPUTTIME", OnSuccessSendData);

        socket.Close();

        if (UIManager.Instance.IsOpened <ConnectingUI>())
        {
            UIManager.Instance.CloseUI <ConnectingUI>();
        }
    }
예제 #4
0
    // playerAuth
    public void SignIn(string id, string passwd)
    {
        data = new Dictionary <string, string>();
        data.Add("id", id);
        data.Add("passwd", passwd);
        jdata = new JSONObject(data);

        socket.Emit("SignIn", jdata);

        socket.On("SignIn", (e) => {
            data = e.data.ToDictionary();
            //Debug.Log(e) ;
            SIRM.SignInSuccess(data);
            socket.Off("SignIn");
        });
    }
예제 #5
0
 void OnConnect(SocketIOEvent e)
 {
     if (!connectedToServer)
     {
         Debug.Log("Connected to server!");
         connectedToServer = true;
         socket.Off("ping", OnConnect);
     }
 }
예제 #6
0
 private void RecieveLeaveStatus(JSONObject response)
 {
     Debug.Log(response);
     if (response.list[0].GetField("status").n == 200)
     {
         socket.Off("game_update", GameUpdate);
         instance = null;
         SceneManager.LoadScene("FindGame");
     }
 }
예제 #7
0
    private void OnUserPlayEnded(SocketIOEvent evt)
    {
        JSONObject roomInfo = evt.data;

        Debug.Log("Get the msg from server is: " + evt.data + " OnUserPlayEnded ");
        socket.Off("MOVE", OnUSerMove);
        socket.Off("BALL_OWNER_CHANGE", OnBallOwnerChange);
        socket.Off("BALL_MOVE", OnBallMove);
        socket.Off("PLAY_TIME_CHANGED", OnTimeChange);
        socket.Off("PLAY_POINT_CHANGED", OnPointChange);


        tableHockeyGameManager.SetCurrentState(TableHockeyGameManager.State.END);
        ballOwner = "";
        ball.transform.position = new Vector3(0f, 0f, 0f);
        ball.GetComponent <TableHockeyBall> ().SetMoveDirection(Vector3.zero);

        tableHockeyGameManager.SetCurrentJoinedRoom(roomInfo);
        tableHockeyGameManager.SetGameView();
    }
 public void KillEventHandler()
 {
     socket.Off("game loaded", gc.startGame);
     socket.Off("player data", gc.setupPlayers);
     socket.Off("submit action", gc.submitAction);
     socket.Off("action start", gc.actionStart);
     socket.Off("end action", gc.actionEnd);
     socket.Off("all actions done", gc.nextTurn);
     socket.Off("game over", gc.endGame);
 }
예제 #9
0
    private void OnGameOver(SocketIOEvent e)
    {
        Debug.Log("Game Over!");
        bool won = Convert.ToBoolean(int.Parse(e.data["won"].ToString()));

        Debug.Log("You won:" + won.ToString());

        foreach (Transform child in map.transform)
        {
            GameObject.Destroy(child.gameObject);
        }

        GameOverPanel.SetActive(true);
        if (!won)
        {
            gameResultText.text = "You Lose :(";
        }

        socket.Off("moveTo", OnMove);
        socket.Off("doorToggle", OnDoorToggle);
        socket.Off("gameOver", OnGameOver);
    }
예제 #10
0
    public void KillEventHandler()
    {
        socket.Off("join game", mc.joinGame);
        socket.Off("ping", mc.pingBack);
        socket.Off("debug", mc.debugMessage);

        //New Acct Menu
        socket.Off("validate name", mc.nameCallback);
        socket.Off("validate email", mc.emailCallback);
        socket.Off("make account", mc.makeAccountCallback);
        socket.Off("login", mc.loginCallback);

        //Menu
        socket.Off("query loadouts", mc.loadoutCallback);
    }
예제 #11
0
    //This function is called when the server responds to Connection Test.
    //The client stops pinging the server and enables the main Game Logic.
    public void NetTest(SocketIOEvent socketEvent)
    {
        //Process Data from the Server.
        isConnected = true;
        string data = socketEvent.data.ToString();

        Debug.Log("Response from server: " + data);
        StopCoroutine("ConnectionTest");
        socket.Off("ConnectionTest", NetTest);
        //Enable Game Logic in the Scene.
        //GameObject go = GameObject.FindGameObjectWithTag ("GameController");
        //gameManager = go.GetComponent<GameManager> ();
        //((MonoBehaviour)gameManager).enabled = true;
        socket.Emit("JoinRoom");
    }
예제 #12
0
 void OnDestroy()
 {
     socket.Off("initpos", laneController.MovePlayer);
     socket.Off("posed", OnPosed);
     socket.Off("hit", OnHit);
 }
예제 #13
0
 private void OnDestroy()
 {
     _network.Off("listRoom", _getRoomInfo);
     _network.Off("joinRoom", _joinRoomResult);
     _network.Off("startGame", _startGame);
 }
 private void OnDestroy()
 {
     //free socket resources...
     socket.Off("push", HandlePush);
 }
예제 #15
0
 public void Off(string ev, System.Action <SocketIOEvent> callback)
 {
     IO.Off(ev, callback);
 }
예제 #16
0
 // reconnect logic
 private void Reconnect(SocketIOEvent obj)
 {
     Debug.Log("Reconnect");
     IoComponent.Off("disconnect", Reconnect);
     IoComponent.Connect();
 }
예제 #17
0
 public void DropHandler(string ev, Action <SocketIOEvent> action)
 {
     socket.Off(ev, action);
 }