Example #1
0
 public override void ClientDisconnect(RPCUserInfo userInfo)
 {
     if (UserList.Contains(userInfo))
     {
         UserList.Remove(userInfo);
     }
 }
Example #2
0
        public override void ClientDisconnect(RPCUserInfo userInfo)
        {
            if (UserList.Contains(userInfo))
            {
                UserList.Remove(userInfo);
            }

        }
Example #3
0
 public override void ClientDisconnect(RPCUserInfo userInfo)
 {
     if (UserList.Contains(userInfo))
     {
         UserList.Remove(userInfo);
         Console.WriteLine((userInfo.UserToken as UserInfo).UserName + " 退出");
     }
 }
Example #4
0
        /// <summary>
        /// 用户断开服务器触发
        /// </summary>
        /// <param name="userInfo"></param>
        public override void ClientDisconnect(RPCUserInfo userInfo)
        {
            if (userInfo.UserToken != null)
            {
                UserInfo user = userInfo.UserToken as UserInfo;
                if (user != null)
                {
                    string key = user.UserName;
                    SpinWait.SpinUntil(() => UserList.TryRemove(key, out user)); //删除列表
                }
            }

            UpdateUserList(this, UserList);
            SendUpdateUserlist();
        }
Example #5
0
        private void DataOn(byte[] data, RPCUserInfo user)
        {
            ReadBytes read;
            int cmd;
          

            if (Service.CallModule(data, user, out read, out cmd))
            {
              
            }
            else
            {
                if (BinaryInputOther != null)
                    BinaryInputOther(read, cmd);
            }
        }
Example #6
0
        /// <summary>
        /// 创建注册 RPGUSERINFO
        /// </summary>
        /// <param name="socketAsync"></param>
        /// <returns></returns>
        private RPCUserInfo NewRPCUserInfo(SocketAsyncEventArgs socketAsync)
        {
            RPCUserInfo tmp = new RPCUserInfo(socketAsync);         
            tmp.RPC_Call.ErrMsgOut += RPC_Call_ErrMsgOut;
            foreach (var item in RegModule)
            {
                tmp.RPC_Call.RegModule(item);
            }

            return tmp;
        }
Example #7
0
 public virtual void ClientDisconnect(RPCUserInfo userInfo)
 {
     return;
 }
Example #8
0
 public override void ClientDisconnect(RPCUserInfo userInfo)
 {
     if (UserList.Contains(userInfo))
     {
         UserList.Remove(userInfo);
         Console.WriteLine((userInfo.UserToken as UserInfo).UserName + " 退出");
     }
 }
Example #9
0
        /// <summary>
        /// 调用模块
        /// </summary>
        /// <param name="data"></param>
        /// <returns>true 属于次模块,false 不属于此模块数据</returns>
        public bool CallModule(byte[] data, RPCUserInfo e,out ReadBytes read,out int cmd)
        {
           

            cmd = -1;

            read = new ReadBytes(data);

            int lengt;          

            if (read.ReadInt32(out lengt) && read.Length == lengt && read.ReadInt32(out cmd))
            {
                switch (cmd)
                {
                    case 1001000:
                        {

                            RPCCallPack tmp;

                            if (read.ReadObject<RPCCallPack>(out tmp))
                            {

                                System.Threading.Tasks.Task.Factory.StartNew(() =>
                                 {
                                     object returnValue;

                                     CallContext.SetData("Current", e);

                                     if (e.RPC_Call.RunModule(tmp, out returnValue))
                                     {
                                         if (tmp.IsNeedReturn)
                                         {
                                             ZYClient_Result_Return var = new ZYClient_Result_Return()
                                             {
                                                 Id = tmp.Id,
                                                 CallTime = tmp.CallTime,
                                                 Arguments = tmp.Arguments
                                             };

                                             if (returnValue != null)
                                             {
                                                 var.Return = Serialization.PackSingleObject(returnValue.GetType(), returnValue);
                                                 var.ReturnType = returnValue.GetType();
                                             }

                                             e.EnsureSend(BufferFormat.FormatFCA(var));
                                         }

                                     }

                                 }, CancellationToken.None, TaskCreationOptions.None, e.QueueScheduler).ContinueWith(p =>
                                     {
                                         try
                                         {
                                             p.Wait();
                                         }
                                         catch (Exception er)
                                         {
                                             if (MsgOut != null)
                                                 MsgOut(er.ToString());
                                         }

                                     });
                             

                                return true;
                            }
                        }
                        break;
                    case 1001001:
                        {
                            ZYClient_Result_Return val;

                            if (read.ReadObject<ZYClient_Result_Return>(out val))
                            {
                                e.RPC_Call.SetReturnValue(val);

                                return true;
                            }
                        }
                        break;

                }
            }

            return false;

        }
Example #10
0
        public void Disconnect(RPCUserInfo e)
        {
            foreach (var item in e.RPC_Call.ModuleDiy.Values)
            {
                Type type = item.GetType();

                if (type.BaseType == typeof(RPCObject))
                {
                    type.GetMethod("ClientDisconnect").Invoke(item, new[] { e });

                }

            }
        }