Beispiel #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);
            }
        }
Beispiel #2
0
 void IGhostRequest.Request(ClientToServerOpCode code, byte[] args)
 {
     _Sends.Enqueue(
         new RequestPackage()
     {
         Data = args,
         Code = code
     });
 }
Beispiel #3
0
 void IGhostRequest.Request(ClientToServerOpCode code, byte[] args)
 {
     lock (_Requests)
     {
         _Requests.Enqueue(
             new RequestPackage
         {
             Code = code,
             Data = args
         });
     }
 }
Beispiel #4
0
 void IGhostRequest.Request(ClientToServerOpCode code, byte[] args)
 {
     lock(_Requests)
     {
         _Requests.Enqueue(
             new RequestPackage
             {
                 Code = code,
                 Data = args
             });
     }
 }
Beispiel #5
0
 void IGhostRequest.Request(ClientToServerOpCode code, byte[] args)
 {
     lock (OnlineStage._LockRequest)
     {
         _Sends.Enqueue(
             new RequestPackage()
         {
             Data = args,
             Code = code
         });
         OnlineStage.RequestQueueCount++;
     }
 }
Beispiel #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);
            }
        }
Beispiel #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);
            }
        }
Beispiel #8
0
 void IGhostRequest.Request(ClientToServerOpCode code, byte[] args)
 {
     lock(OnlineStage._LockRequest)
     {
         _Sends.Enqueue(
             new RequestPackage()
             {
                 Data = args,
                 Code = code
             });
         OnlineStage.RequestQueueCount++;
     }
 }