public override void OnPacket(NetworkClient client, ProcessedPacket packet) { var cmd = new VMNetCommand(); try { using (var reader = new BinaryReader(packet)) { cmd.Deserialize(reader); } } catch (Exception) { ClientsToDC.Add(client); return; } if (cmd.Type == VMCommandType.SimJoin) { if (SandboxBans.Contains(client.RemoteIP)) { SendGenericMessage(client, "Banned", "You have been banned from this sandbox server!"); ClientsToDC.Add(client); return; } else if (((VMNetSimJoinCmd)cmd.Command).Version != VMNetSimJoinCmd.CurVer) { SendGenericMessage(client, "Version Mismatch", "Your game version does not match the server's. Please update your game."); ClientsToDC.Add(client); return; } ((VMNetSimJoinCmd)cmd.Command).Ticket = client.RemoteIP + ":" + ((VMNetSimJoinCmd)cmd.Command).Name; ((VMNetSimJoinCmd)cmd.Command).Client = client; //remember client so we can bind it to persist id later SendCommand(cmd.Command); //just go for it. will start the avatar retrieval process. return; } else if (cmd.Type == VMCommandType.RequestResync) { lock (ClientsToSync) { //todo: throttle ClientsToSync.Add(client); } } lock (ClientToUID) { if (!ClientToUID.ContainsKey(client)) { return; //client hasn't registered yet } cmd.Command.ActorUID = ClientToUID[client]; } SendCommand(cmd.Command); }
private void HandleServerMessage(VMNetMessage message) { if (message.Type == VMNetMessageType.Direct) { var cmd = new VMNetCommand(); try { using (var reader = new BinaryReader(new MemoryStream(message.Data))) { cmd.Deserialize(reader); } cmd.Command.Execute(VMHook, VMHook.GetAvatarByPersist(cmd.Command.ActorUID)); } catch (Exception e) { CloseReason = VMCloseNetReason.NetExceptionDirect; CloseString = "An exception occurred while running a direct tick from the server, so the lot connection was terminated: \n\n" + e.ToString(); Shutdown(); return; } } else { var tick = new VMNetTickList(); try { using (var reader = new BinaryReader(new MemoryStream(message.Data))) { tick.Deserialize(reader); } } catch (Exception e) { CloseReason = VMCloseNetReason.NetException; CloseString = "An exception occurred while running a broadcast tick from the server, so the lot connection was terminated: \n\n" + e.ToString(); Shutdown(); return; } for (int i = 0; i < tick.Ticks.Count; i++) { tick.Ticks[i].ImmediateMode = tick.ImmediateMode; TickBuffer.Enqueue(tick.Ticks[i]); } } }
private void HandleServerMessage(VMNetMessage message) { if (message.Type == VMNetMessageType.Direct) { var cmd = new VMNetCommand(); try { using (var reader = new BinaryReader(new MemoryStream(message.Data))) { cmd.Deserialize(reader); } cmd.Command.Execute(VMHook); } catch (Exception e) { Shutdown(); return; } } else { var tick = new VMNetTickList(); try { using (var reader = new BinaryReader(new MemoryStream(message.Data))) { tick.Deserialize(reader); } } catch (Exception e) { Shutdown(); return; } for (int i = 0; i < tick.Ticks.Count; i++) { tick.Ticks[i].ImmediateMode = tick.ImmediateMode; TickBuffer.Enqueue(tick.Ticks[i]); } } }
public override void OnPacket(NetworkClient client, ProcessedPacket packet) { var cmd = new VMNetCommand(); try { using (var reader = new BinaryReader(packet)) { cmd.Deserialize(reader); } } catch (Exception) { ClientsToDC.Add(client); return; } if (cmd.Type == VMCommandType.SimJoin) { if (((VMNetSimJoinCmd)cmd.Command).Version != VMNetSimJoinCmd.CurVer) { ClientsToDC.Add(client); return; } lock (UIDs) { UIDs.Add(client, ((VMNetSimJoinCmd)cmd.Command).SimID); } } else if (cmd.Type == VMCommandType.RequestResync) { lock (ClientsToSync) { //todo: throttle ClientsToSync.Add(client); } } SendCommand(cmd.Command); }