Leave() public method

public Leave ( byte player ) : void
player byte
return void
Beispiel #1
0
        public void Leave(byte player)
        {
            PlayerInfo info = State.Instance.GetPlayer(_sender);

            // If the client is not registered, do nothing
            if (info == null)
            {
                return;
            }
            State.Instance.RemoveClient(info);
            info.Connected = false;
            // Notify everybody that the player has left the game
            _broadcaster.Leave(info.Id);
            if (State.Instance.Engine.IsLocal != false)
            {
                return;
            }
            var mess = new GameMessage();

            // don't send if we join our own room...that'd be annoying
            if (info.Nick.Equals(State.Instance.Engine.Game.HostUserName, StringComparison.InvariantCultureIgnoreCase))
            {
                return;
            }
            mess.Message   = string.Format("{0} has left your game", info.Nick);
            mess.Sent      = DateTime.Now;
            mess.SessionId = State.Instance.Engine.Game.Id;
            mess.Type      = GameMessageType.Event;
            new Octgn.Site.Api.ApiClient().GameMessage(State.Instance.Engine.ApiKey, mess);
        }
Beispiel #2
0
        public void Leave(byte player)
        {
            PlayerInfo info = State.Instance.GetPlayer(_sender);

            // If the client is not registered, do nothing
            if (info == null)
            {
                return;
            }
            State.Instance.RemoveClient(info);
            info.Connected = false;
            // Notify everybody that the player has left the game
            _broadcaster.Leave(info.Id);
        }
Beispiel #3
0
        // Called when a client is unexpectedly disconnected
        internal void Disconnected(TcpClient client)
        {
            PlayerInfo info;

            // If the client is not registered, do nothing
            if (!_clients.TryGetValue(client, out info))
            {
                return;
            }
            // Remove the client from our lists
            _clients.Remove(client);
            _players.Remove(info.Id);
            // Notify everybody that the player has left the game
            _broadcaster.Leave(info.Id);
        }