Ejemplo n.º 1
0
        private bool CheckMessage(IMessage message, PhotonServerPeer peer, Dictionary <int, PhotonServerHandler> list, PhotonServerHandler defaultHandler)
        {
            var handled = false;

            if (message.SubCode.HasValue && list.ContainsKey(message.SubCode.Value))
            {
                list[message.SubCode.Value].HandleMessage(message, peer);
                handled = true;
            }
            else if (!message.SubCode.HasValue && list.ContainsKey(message.Code))
            {
                list[message.Code].HandleMessage(message, peer);
                handled = true;
            }
            else
            {
                defaultHandler.HandleMessage(message, peer);
            }

            return(handled);
        }
Ejemplo n.º 2
0
        public bool HandleMessage(IMessage message, PhotonServerPeer peer)
        {
            bool handled = false;

            switch (message.Type)
            {
            case MessageType.Request:
                handled = CheckMessage(message, peer, _requestHandlerList, _defaultRequestHandler);
                break;

            case MessageType.Response:
                handled = CheckMessage(message, peer, _responseHandlerList, _defaultResponseHandler);
                break;

            case MessageType.Async:
                handled = CheckMessage(message, peer, _eventsHandlerList, _defaultEventHandler);
                break;
            }

            return(handled);
        }