Esempio n. 1
0
        public bool PushRequest(uint id, string method, byte[] content)
        {
            ProtoCall call;

            if (this.protos.TryGetValue(method, out call) && null != call.Handler)
            {
                Logger <IGiantLightServer> .L(string.Format("PushRequest {0}:{1}.", this.service, method));

                Queue <uint> queue = null;
                if (this.calls.TryGetValue(method, out queue))
                {
                    queue.Enqueue(id);
                }
                else
                {
                    queue = new Queue <uint>();
                    queue.Enqueue(id);
                    this.calls.Add(method, queue);
                }

                var request = ByteConverter.BytesToProtoBuf(call.Type, content, 0, content.Length);
                call.Handler.DynamicInvoke(method, request);

                return(true);
            }

            Logger <IGiantLightServer> .W(string.Format("CANNOT find [{0}] handler for [{1}] service!", method, this.service));

            return(false);
        }
Esempio n. 2
0
        public bool PushResponse(string method, byte[] content)
        {
            ProtoCall call;

            if (this.protos.TryGetValue(method, out call))
            {
                if (null != call.Handler)
                {
                    Logger <IGiantLightServer> .L(string.Format("PullResponse {0}:{1}.", this.service, method));

                    var response = ByteConverter.BytesToProtoBuf(call.Type, content, 0, content.Length);
                    call.Handler.DynamicInvoke(method, response);
                }

                return(true);
            }

            Logger <IGiantLightServer> .W(string.Format("CANNOT find [{0}] handler for [{1}] service!", method, this.service));

            return(false);
        }