Exemplo n.º 1
0
        public MultiPlayerClient(IClientNetworkProvider networkProvider)
        {
            this.clientNetworkProvider = networkProvider;
            networkProvider.MessageReceived.SubscribeForLifetime((m) =>
            {
                var hydratedEvent = MultiPlayerMessage.Deserialize(m);
                EventRouter.Route(hydratedEvent.GetType().Name, hydratedEvent);
            }, this);
            this.OnDisposed(() =>
            {
                if (isConnected)
                {
                    TrySendMessage(new LeftMessage()
                    {
                        ClientWhoLeft = this.ClientId
                    });
                }
                this.clientNetworkProvider.Dispose();
            });

            EventRouter.Register <Ack>(OnAck, this);
        }
Exemplo n.º 2
0
        private void OnRawMessageReceived(string messageText)
        {
            var hydratedMessage = MultiPlayerMessage.Deserialize(messageText);

            MessageRouter.Route(hydratedMessage.GetType().Name, hydratedMessage);
        }