private void ReceiveClientStatus(BaseProtocol protocol)
    {
        StatusProtocol clientStatus = protocol as StatusProtocol;

        if (clientStatus.IsType(StatusProtocol.Type.Client))
        {
            PrintToConsole(string.Format("{0} has {1} the server", clientStatus.from_client, (clientStatus.ok ? "connected to" : "disconnected from")));
        }
    }
Example #2
0
    void Join_Game(BaseProtocol protocol)
    {
        StatusProtocol status = protocol as StatusProtocol;

        if (status.IsType(StatusProtocol.Type.Game) && status.ok)
        {
            SceneManager.LoadScene("GameLobby", LoadSceneMode.Single);
            SocketClient.ActiveGameData.SetGameStatus(GameData.GameStatus.Active);
        }
    }
Example #3
0
    void GetAvailableGames(BaseProtocol protocol)
    {
        StatusProtocol serverStatus = protocol as StatusProtocol;

        if (!serverStatus.IsType(StatusProtocol.Type.Server) || !serverStatus.ok)
        {
            return;                                                                           // oppsie we've been bad.... :(
        }
        print("Status Ok: " + serverStatus.ok);
        StartRequesting();
    }
Example #4
0
    private void ErrorDisconnect()
    {
        // make sure the socket is dead.
        try
        {
            socket.Close();
        }
        catch {}

        Reset = true;

        print("Helloo World");

        // Add a server error to the inbound cue.
        // to let the game know that an error has occored.
        StatusProtocol serverStatus = new StatusProtocol();

        serverStatus.ok      = false;
        serverStatus.message = "Server disconnected!";
        serverStatus.SetMessageType(StatusProtocol.Type.Server);
        serverStatus.from_client = GameData.GAME_CLIENT_NAME;

        inboundQueue.Enqueue(serverStatus);
    }