Esempio n. 1
0
 private void _Server_ClientDisconnected(object sender, ServerEvent e)
 {
     Invoke((MethodInvoker) delegate
     {
         RefreshUI();
     });
 }
Esempio n. 2
0
 private void _Server_ServerInfo(object sender, ServerEvent e)
 {
     Invoke((MethodInvoker) delegate
     {
         Log(e.Message, e.ColorCode);
     });
 }
Esempio n. 3
0
 private void _Server_MetricInfo(object sender, ServerEvent e)
 {
     Invoke((MethodInvoker) delegate
     {
         StatusText.Text = e.Message;
     });
 }
Esempio n. 4
0
        private void HandleConnection(Connection connection)
        {
            IPEndPoint ipe = (IPEndPoint)connection.ConnectionInfo.RemoteEndPoint;
            //string s = connection.ConnectionInfo.RemoteIPEndPoint.Address + ":" + connection.ConnectionInfo.RemoteIPEndPoint.Port;
            string s = ipe.Address + ":" + ipe.Port;

            if ((ipe.Address.ToString() == ServerIPAddress) &&
                (ipe.Port == ServerPort))
            {
                return;
            }

            MClient c = new MClient();

            c.State            = MClient.STATE_CONNECTING;
            c.connection       = connection;
            c.Address          = ipe.Address;
            c.Port             = ipe.Port;
            c.Account.ClientIP = ipe.Address.ToString();
            MassiveConnections.Add(c);

            if (ClientConnected != null)
            {
                ServerEvent se = new ServerEvent("CONNECTED");
                se.Client = c;
                ClientConnected(this, se);
            }

            Log("Connected:" + c.ToString(), UTILITY);

            MNetMessage m     = new MNetMessage();
            int         Count = MassiveConnections.Count;

            if (Count < MAXCONNECTIONS)
            {
                m.Command = MNetMessage.READY;
                m.UserID  = MNetMessage.SERVER;
                Send(c, "Message", m.Serialize());
            }
            else
            {
                DisconnectClient(connection, "Maximum Connections Reached. Please try a different server, or come back later.");
            }
        }
Esempio n. 5
0
        private void HandleConnectionClosed(Connection connection)
        {
            //IPEndPoint ipe = (IPEndPoint)connection.ConnectionInfo.RemoteEndPoint;
            //string s = ipe.Address + ":" + ipe.Port;

            MClient ToRemove = null;

            foreach (MClient m in MassiveConnections)
            {
                if (m.connection == connection)
                {
                    ToRemove = m;
                }
            }

            _DataBase.RemoveUserFromUniverse(ToRemove.Account.UserID);
            //CurrentUniverse.Cleanup(ToRemove.Account.UserID);

            if (ToRemove != null)
            {
                ToRemove.Account.LastActivity = DateTime.Now;
                ToRemove.Save();
                MassiveConnections.Remove(ToRemove);
            }

            if (ClientDisconnected != null)
            {
                ServerEvent se = new ServerEvent("DISCONNECTED");
                ClientDisconnected(this, se);
            }

            MNetMessage mn = new MNetMessage();

            mn.Command = MNetMessage.LOGGEDOUT;
            mn.UserID  = ToRemove.Account.UserID;
            SendToAllClients(ToRemove, mn.Serialize());

            Log("Disconnected:" + ToRemove.ToString(), UTILITY);
        }
Esempio n. 6
0
 private void _Server_ClientLoggedIn(object sender, ServerEvent e)
 {
     RefreshUI();
 }
Esempio n. 7
0
 private void _Server_UniverseChanged(object sender, ServerEvent e)
 {
     Log(e.Message, e.ColorCode);
     RefreshUI();
 }