示例#1
0
 void NcsServer_UserClosed(NcsUser user, CloseReason reason)
 {
     user.instance_die = true;
     lock (user_list)
     {
         for (int i = 0; i < Program.space_max; i++)
         {
             user_list[i].Remove(user);
         }
     }
 }
示例#2
0
 void UserSpace(NcsUser user, int space)
 {
     lock (user_list)
     {
         for (int i = 0; i < Program.space_max; i++)
         {
             user_list[i].Remove(user);
         }
         user_list[space].Add(user);
         user.space = space;
     }
 }
示例#3
0
        void NcsServer_NewRequestReceived(NcsUser user, NcsRequestInfo requestInfo)
        {
            NcsBuffer buffer     = new NcsBuffer(requestInfo.Body);
            int       space_type = buffer.pop_sint16();
            int       signal     = buffer.pop_sint16();

            // Send To Server
            if (requestInfo.Key == Program.SendToServer)
            {
                switch (signal)
                {
                case Program.signal_heartbeat_first:
                {
                    NcsBuffer heartbeat_buffer = new NcsBuffer(Program.signal_heartbeat_second, Program.SendToClient, Program.MySpace);
                    heartbeat_buffer.push_size();
                    user.Send(heartbeat_buffer.write_buffer, 0, heartbeat_buffer.write_offset);
                    user.heartbeat = true;
                }
                break;

                case Program.signal_login:
                {
                    Console.WriteLine("Login : "******"unvaild : " + signal);
                }
                break;
                }
            }

            // Send To Client
            else if (requestInfo.Key == Program.SendToClient)
            {
                if (user.authentication == true)
                {
                    switch (space_type)
                    {
                    case Program.MySpace:
                    {
                        foreach (NcsUser index in user_list[user.space])
                        {
                            if (index != user)
                            {
                                index.Send(requestInfo.Buffer, 0, requestInfo.Buffer.Length);
                            }
                        }
                    }
                    break;

                    case Program.AllSpace:
                    {
                        for (int i = 0; i < Program.space_max; i++)
                        {
                            foreach (NcsUser index in user_list[i])
                            {
                                if (index != user)
                                {
                                    index.Send(requestInfo.Buffer, 0, requestInfo.Buffer.Length);
                                }
                            }
                        }
                    }
                    break;

                    default:
                    {
                        foreach (NcsUser index in user_list[space_type])
                        {
                            if (index != user)
                            {
                                index.Send(requestInfo.Buffer, 0, requestInfo.Buffer.Length);
                            }
                        }
                    }
                    break;
                    }
                }
            }
        }
示例#4
0
 void NcsServer_NewUserConnected(NcsUser user)
 {
     user.heartbeat_start();
 }