void HandleSeverMessage(NetIncomingMessage msg)
        {
            MessageFunction type = (MessageFunction)msg.ReadInt32();
            switch (type)
            {
                case MessageFunction.ClassMessage:
                    SendTo sendTo = (SendTo)msg.ReadInt32();
                    string assemblyName = msg.ReadString();
                    string classType = msg.ReadString();
                    Message report = (Message)Activator.CreateInstance(assemblyName, classType).Unwrap();
                    msg.ReadAllFields(report);
                    SendNetworkMessage(report, sendTo, msg);
                    break;
                case MessageFunction.SpawnPlayer:
                    // broadcast this to all connections, except sender
                    List<NetConnection> all2 = m_server.Connections; // get copy
                    all2.Remove(msg.SenderConnection);

                    int id2 = msg.ReadInt32();
                    string playerName = msg.ReadString();
                    if (all2.Count > 0)
                    {
                        NetOutgoingMessage om = m_server.CreateMessage();
                        om.Write((int)MessageFunction.SpawnPlayer);
                        om.Write(id2);
                        om.Write(playerName);

                        m_server.SendMessage(om, all2, NetDeliveryMethod.ReliableUnordered, 0);
                    }
                    SpawnPlayer(id2, playerName, msg.SenderConnection);
                    break;
                default:
                    Debug.LogWarning("Unhandled msg type: " + type.ToString());
                    break;
            }
        }
        void HandleClientMessage(NetIncomingMessage msg)
        {
            MessageFunction type = (MessageFunction)msg.ReadInt32();
            switch (type)
            {
                case MessageFunction.ClassMessage:
                    string assemblyName = msg.ReadString();
                    string classType = msg.ReadString();
                    Message report = (Message)Activator.CreateInstance(assemblyName, classType).Unwrap();
                    msg.ReadAllFields(report);
                    report.OnCalled(report, msg);
                    break;
                case MessageFunction.SpawnAllPlayer:
                    int count = msg.ReadInt32();
                    for (int i = 0; i < count; i++)
                    {
                        int id = msg.ReadInt32();
                        string playerName = msg.ReadString();

                        SpawnPlayer(id, playerName);
                    }

                    int newId = SpawnLocalPlayer();
                    MessageSpawnPlayer spawnMessage = new MessageSpawnPlayer();
                    spawnMessage.playerId = newId;
                    spawnMessage.playerName = Steam.personaName;
                    SendNetworkMessage(spawnMessage, SendTo.Others);
                    break;
                case MessageFunction.UpdateVehiclesPositions:
                    m_vNetworkManager.UpdateCarsPositions(msg);
                    break;
                case MessageFunction.RemoveVehicle:
                    int carID2 = msg.ReadInt32();
                    m_vNetworkManager.RemoveCar(carID2);
                    break;
                case MessageFunction.UpdateCitizensPositions:
                    m_cNetworkManager.UpdateCitizensPositions(msg);
                    break;
                default:
                    Debug.LogWarning("Unhandled msg type: " + type.ToString());
                    break;
            }
        }