Exemplo n.º 1
0
        public override void HandleMessage(INetPacketStream packet)
        {
            var type = packet.Read <int>();
            var json = packet.Read <string>();

            switch (type)
            {
            case 0:
                OnCombatLogReceived(CombatLogJsonParser.ParseString(json));
                break;

            case 1:
                OnGameStateReceived(GameStateEntry.FromString(json));
                break;

            default:
                throw new Exception("Unexcepted type!");
            }
        }
Exemplo n.º 2
0
        private void contextReceived(Task <HttpListenerContext> task)
        {
            try
            {
                var context = task.Result;
                var request = context.Request;

                var combatLogEntry = CombatLogJsonParser.ParseStream(request.InputStream);

                OnDataReceived(combatLogEntry);

                var response = context.Response;
                response.StatusCode = 200;
                response.Close();

                receiveContext();
            }
            catch (Exception e)
            {
                OnError(e);
            }
        }