private void onMessage(LimeMessage msg) { var msgType = msg.GetType(); if (context.config.logMessages) { Global.log.trace($"received message {msgType.Name} from {msg.source}"); } // dynamically resolve the handlers if (handlers.canHandle(msgType)) { var handler = handlers.resolve(msgType); var status = handler.handle(msg); } else { Global.log.err($"no handler found for {msgType.Name}"); } // update last message time var client = context.clients.Single(x => x.uid == msg.source.RemoteUniqueIdentifier); client.lastMessage = stopwatch.ElapsedMilliseconds; }
protected virtual void onMessage(LimeMessage msg) { var msgType = msg.GetType(); if (msg is GameUpdateMessage gameUpdateMessage) { // preprocess all game updates preprocessGameUpdate(gameUpdateMessage); #if DEBUG if (debug) { Global.log.trace($"received game update {gameUpdateMessage} from {msg.source}"); } #endif } else { // log misc message #if DEBUG if (debug) { Global.log.trace($"received message {msgType.Name} from {msg.source}"); } #endif } if (handlers.canHandle(msgType)) { var handler = handlers.resolve(msgType); var handled = handler.handle(msg); } else { Global.log.err($"no handler found for {msgType.Name}"); } }