Exemplo n.º 1
0
        void OnStatusChange(object sender, NetStatusEventArgs e)
        {
            m_log.Info(e.Connection + ": " + e.Connection.Status + " - " + e.Reason);
            if (e.Connection.Status == NetConnectionStatus.Connected)
            {
                NetMessage outMsg = new NetMessage();
                outMsg.Write("MSG:Server:Welcome:0.01:" + m_players.Count);
                Server.SendMessage(outMsg, e.Connection, NetChannel.Unreliable);
                NetPlayer ins = new NetPlayer(e.Connection, "");
                m_players.Add(ins);
                Console.WriteLine("Client connected; " + Server.NumConnected + " of 100");
            }

            if (e.Connection.Status == NetConnectionStatus.Disconnected)
            {
                //HaveDeconnection = true;
                //RemoveDeconnectedPlayer();
                for (int i = 0; i < m_players.Count; i++)
                {
                    NetPlayer tmp = m_players[i];
                    if (tmp.PlayerConnection == e.Connection)
                    {
                        if (tmp.CurrentRoom != null)
                        {
                            tmp.CurrentRoom.Send("ROM:PLAYER:LEAVE:" + tmp.GetName(), null);
                            tmp.CurrentRoom.RemovePlayer(tmp);
                        }
                        m_players.Remove(tmp);
                    }
                }
            }
        }
Exemplo n.º 2
0
 private void StatusChanged(object sender, NetStatusEventArgs e)
 {
     m_log.Info(e.Connection + ": " + e.Connection.Status + " - " + e.Reason);
 }