Пример #1
0
        private void _Apportion(ClientToServerOpCode code, byte[] args)
        {
            switch (code)
            {
            case ClientToServerOpCode.Ping:
                OnPingEvent?.Invoke();
                break;

            case ClientToServerOpCode.CallMethod:
            {
                var pkg = args.ToPackageData <PackageCallMethod>(_Serializer);

                OnCallMethodEvent?.Invoke(pkg.EntityId, pkg.MethodId, pkg.ReturnId, pkg.MethodParams);
            }

            break;

            case ClientToServerOpCode.Release:
            {
                var pkg = args.ToPackageData <PackageRelease>(_Serializer);

                OnReleaseEvent?.Invoke(pkg.EntityId);
            }

            break;

            default:
                throw new ArgumentOutOfRangeException(nameof(code), code, null);
            }
        }
Пример #2
0
 void IGhostRequest.Request(ClientToServerOpCode code, byte[] args)
 {
     _Sends.Enqueue(
         new RequestPackage()
     {
         Data = args,
         Code = code
     });
 }
Пример #3
0
 void IGhostRequest.Request(ClientToServerOpCode code, byte[] args)
 {
     lock (_Requests)
     {
         _Requests.Enqueue(
             new RequestPackage
         {
             Code = code,
             Data = args
         });
     }
 }
Пример #4
0
 void IGhostRequest.Request(ClientToServerOpCode code, byte[] args)
 {
     lock(_Requests)
     {
         _Requests.Enqueue(
             new RequestPackage
             {
                 Code = code,
                 Data = args
             });
     }
 }
Пример #5
0
 void IGhostRequest.Request(ClientToServerOpCode code, byte[] args)
 {
     lock (OnlineStage._LockRequest)
     {
         _Sends.Enqueue(
             new RequestPackage()
         {
             Data = args,
             Code = code
         });
         OnlineStage.RequestQueueCount++;
     }
 }
Пример #6
0
        private void _Apportion(ClientToServerOpCode code, byte[] args)
        {
            if(ClientToServerOpCode.Ping == code)
            {
                if(PingEvent != null)
                {
                    PingEvent();
                }
            }
            else if(ClientToServerOpCode.CallMethod == code)
            {

                /*var EntityId = new Guid(args[0]);

                var MethodName = Encoding.Default.GetString(args[1]);

                byte[] par = null;
                var ReturnId = Guid.Empty;
                if(args.TryGetValue(2, out par))
                {
                    ReturnId = new Guid(par);
                }

                var MethodParams = (from p in args
                                    where p.Key >= 3
                                    orderby p.Key
                                    select p.Value).ToArray();*/

                var data = args.ToPackageData<PackageCallMethod>();
                if (CallMethodEvent != null)
                {

                    CallMethodEvent(data.EntityId, data.MethodName, data.ReturnId, data.MethodParams);
                }
            }
            else if(ClientToServerOpCode.Release == code)
            {
                var data = args.ToPackageData<PackageRelease>();
                //var EntityId = new Guid(args[0]);
                ReleaseEvent(data.EntityId);
            }
        }
Пример #7
0
        private void _Apportion(ClientToServerOpCode code, byte[] args)
        {
            if (ClientToServerOpCode.Ping == code)
            {
                if (PingEvent != null)
                {
                    PingEvent();
                }
            }
            else if (ClientToServerOpCode.CallMethod == code)
            {
                /*var EntityId = new Guid(args[0]);
                 *
                 * var MethodId = Encoding.Default.GetString(args[1]);
                 *
                 * byte[] par = null;
                 * var ReturnId = Guid.Empty;
                 * if(args.TryGetValue(2, out par))
                 * {
                 *      ReturnId = new Guid(par);
                 * }
                 *
                 * var MethodParams = (from p in args
                 *                  where p.Key >= 3
                 *                  orderby p.Key
                 *                  select p.Value).ToArray();*/


                var data = args.ToPackageData <PackageCallMethod>(_Serializer);
                if (CallMethodEvent != null)
                {
                    CallMethodEvent(data.EntityId, data.MethodId, data.ReturnId, data.MethodParams);
                }
            }
            else if (ClientToServerOpCode.Release == code)
            {
                var data = args.ToPackageData <PackageRelease>(_Serializer);
                //var EntityId = new Guid(args[0]);
                ReleaseEvent(data.EntityId);
            }
        }
Пример #8
0
 void IGhostRequest.Request(ClientToServerOpCode code, byte[] args)
 {
     lock(OnlineStage._LockRequest)
     {
         _Sends.Enqueue(
             new RequestPackage()
             {
                 Data = args,
                 Code = code
             });
         OnlineStage.RequestQueueCount++;
     }
 }