public void CreatePlayerListener(CreatePlayerEvent createPlayerEvent)
        {
            var player  = PlayerManager.Instance.FindPlayerByConnectionId(createPlayerEvent.hid);
            var message = WsMessageBuilder.CreateWsMessage("public", _terrainLayer);

            _eventBus.Post(message);
        }
        public override void Process(Entity entity, Army army, GeoEntity geoEntity)
        {
            ArmyChangeEvent armyChangeEvent = new ArmyChangeEvent(army, geoEntity);
            WsMessage       wsMessage       = WsMessageBuilder.CreateWsMessage("public", armyChangeEvent);

            _jEventBus.Post(wsMessage);
        }
        public static object DeserializeMessage(MessageEventArgs e)
        {
            try
            {
                WsMessage receivedMessage    = JsonConvert.DeserializeObject <WsMessage>(e.Data);
                object    incomingRealObject = WsMessageBuilder.ReadWsMessage(receivedMessage);
                return(incomingRealObject);
            }
            catch (Exception exception)
            {
                Debug.WriteLine("Cannot deserialize: " + exception);
            }

            return(null);
        }
        private void PrepareBindings()
        {
            WsMessageBuilder.AddBinding(typeof(CompleteTurnEvent));


            WsMessageBuilder.AddBinding("FindPathEvent", typeof(FindPathRequestEvent));
            WsMessageBuilder.AddBinding(typeof(FindPathRequestEvent));

            WsMessageBuilder.AddBinding("LoginPlayerEvent", typeof(LoginPlayerEvent));
            WsMessageBuilder.AddBinding(typeof(LoginPlayerEvent));

            WsMessageBuilder.AddBinding("AddArmyEvent", typeof(AddArmyEvent));
            WsMessageBuilder.AddBinding(typeof(AddArmyEvent));

            WsMessageBuilder.AddBinding(typeof(TerrainLayer));
        }
        public void SendMessage(object createPlayerEvent, string channel = "public")
        {
            string message = WsMessageBuilder.CreateWsText(channel, createPlayerEvent);

            _webSocket.Send(message);
        }