public new static NewUserPacket FromRaw(RealmData realmData, JObject data) { return(new NewUserPacket { user = User.FromRaw(realmData, (JObject)data["user"]) }); }
private void ProcessPacket(Packet packet) { if (packet is SynchronisationPacket) { // This is the first packet that we receive // It contains all the data of the server SynchronisationPacket syncPacket = (SynchronisationPacket)packet; this.realmData = syncPacket.realmData; this.currentUser = syncPacket.user; this.realmData.PacketToServer += PacketToServerCallback; this.realmData.Log += Log; SaveCredentials(); if (OnUsable != null) { OnUsable(); } } else { packet.Apply(this.currentUser, this.realmData); } }
public static Packet FromRaw(RealmData realmData, JObject data) { string classType = (string)data["type"]; switch (classType) { case AuthentificationPacket.TYPE_CLASS: return(AuthentificationPacket.FromRaw(realmData, data)); case PostMessagePacket.TYPE_CLASS: return(PostMessagePacket.FromRaw(realmData, data)); case SynchronisationPacket.TYPE_CLASS: return(SynchronisationPacket.FromRaw(realmData, data)); case ChatMessagePacket.TYPE_CLASS: return(ChatMessagePacket.FromRaw(realmData, data)); case NewUserPacket.TYPE_CLASS: return(NewUserPacket.FromRaw(realmData, data)); case UserConnectedPacket.TYPE_CLASS: return(UserConnectedPacket.FromRaw(realmData, data)); case ThingReceivedPacket.TYPE_CLASS: return(ThingReceivedPacket.FromRaw(realmData, data)); case SendThingPacket.TYPE_CLASS: return(SendThingPacket.FromRaw(realmData, data)); } throw new Exception("Packet type not found"); }
public PhiClient(string address) { this.address = address; this.realmData = new RealmData(); PhiClient.instance = this; }
public new static ThingReceivedPacket FromRaw(RealmData realmData, JObject data) { return(new ThingReceivedPacket { realmThing = RealmThing.FromRaw(realmData, (JObject)data["realmThing"]), userFrom = ID.Find(realmData.users, (int)data["userFrom"]) }); }
public static ChatMessage FromRaw(RealmData realmData, JObject data) { return(new ChatMessage { user = ID.Find(realmData.users, data.Value <int>("user")), message = data.Value <string>("message") }); }
public new static UserConnectedPacket FromRaw(RealmData realmData, JObject data) { return(new UserConnectedPacket { user = ID.Find(realmData.users, (int)data["user"]), connected = (bool)data["connected"] }); }
public new static SendThingPacket FromRaw(RealmData realmData, JObject data) { return(new SendThingPacket { realmThing = RealmThing.FromRaw(realmData, (JObject)data["realmThing"]), userTo = ID.Find(realmData.users, (int)data["userTo"]) }); }
public override void Apply(User user, RealmData realmData) { Console.WriteLine(user.name + " sending " + realmThing.stackCount + "x" + realmThing.thingDefLabel + " to " + userTo.name); // We rewire the thing to the targeted user realmData.NotifyPacket(userTo, new ThingReceivedPacket { userFrom = user, realmThing = realmThing }); }
public static RealmData FromRaw(JObject data) { RealmData realmData = new RealmData(); realmData.users = ((JArray)data["users"]).Select(du => User.FromRaw(realmData, (JObject)du)).ToList(); realmData.chat = ((JArray)data["chat"]).Select(du => ChatMessage.FromRaw(realmData, (JObject)du)).ToList(); return(realmData); }
public new static SynchronisationPacket FromRaw(RealmData realmData, JObject data) { realmData = RealmData.FromRaw((JObject)data["realmData"]); return(new SynchronisationPacket { realmData = realmData, user = ID.Find(realmData.users, (int)data["user"]) }); }
// Token: 0x06000051 RID: 81 RVA: 0x00003B2A File Offset: 0x00001D2A public override void Apply(User user, RealmData realmData) { user.preferences = preferences; realmData.BroadcastPacketExcept(new UpdatePreferencesNotifyPacket { user = user, preferences = preferences }, user); }
public static User FromRaw(RealmData realmData, JObject data) { return(new User { id = (int)data["id"], name = (string)data["name"], connected = (bool)data["connected"], inGame = (bool)data["inGame"] }); }
public static Packet Deserialize(byte[] data, RealmData realmData, User user) { var context = new RealmContext { realmData = realmData, user = user }; var bf = new BinaryFormatter(null, new StreamingContext(StreamingContextStates.All, context)); var ms = new MemoryStream(data); return((Packet)bf.Deserialize(ms)); }
public static RealmThing FromRaw(RealmData realmData, JObject data) { return(new RealmThing { thingDefLabel = data.Value <string>("thingDefLabel"), stuffDefLabel = data.Value <string>("stuffDefLabel"), stackCount = data.Value <int>("stackCount"), compQuality = data.Value <int>("compQuality"), hitPoints = data.Value <int>("hitPoints") }); }
// No way to set trained skills? public static RealmAnimal ToRealmAnimal(Pawn pawn, RealmData realmData) { string name = pawn.Name.ToStringFull; return(new RealmAnimal { name = name, kindDefName = pawn.kindDef.defName, ageBiologicalTicks = pawn.ageTracker.AgeBiologicalTicks, ageChronologicalTicks = pawn.ageTracker.AgeChronologicalTicks, gender = pawn.gender }); }
public static byte[] Serialize(Packet packet, RealmData realmData, User user) { var context = new RealmContext { realmData = realmData, user = user }; var bf = new BinaryFormatter(null, new StreamingContext(StreamingContextStates.All, context)); var ms = new MemoryStream(); bf.Serialize(ms, packet); return(ms.ToArray()); }
// Token: 0x0600001B RID: 27 RVA: 0x00002370 File Offset: 0x00000570 public static Packet Deserialize(byte[] data, RealmData realmData, User user) { var realmContext = new RealmContext { realmData = realmData, user = user }; var binaryFormatter = new BinaryFormatter(null, new StreamingContext(StreamingContextStates.All, realmContext)); var serializationStream = new MemoryStream(data); return((Packet)binaryFormatter.Deserialize(serializationStream)); }
// Token: 0x06000008 RID: 8 RVA: 0x00002268 File Offset: 0x00000468 private void ProcessPacket(Packet packet) { if (packet is SynchronisationPacket synchronisationPacket) { realmData = synchronisationPacket.realmData; currentUser = synchronisationPacket.user; realmData.PacketToServer += PacketToServerCallback; realmData.Log += Log; SaveCredentials(); OnUsable?.Invoke(); } else { packet.Apply(currentUser, realmData); } }
public override void Apply(User user, RealmData realmData) { // Is this nick available ? if (realmData.users.Any((u) => u.name == name)) { realmData.NotifyPacket(user, new ErrorPacket { error = "Nickname " + name + " is already taken" }); return; } user.name = name; realmData.BroadcastPacket(new ChangeNicknameNotifyPacket { user = user, name = name }); }
public void TryConnect() { // We clean the old states if (this.client != null) { this.client.Disconnect(); this.realmData = null; } this.client = new Client(this.address, PORT); this.client.Connection += this.ConnectionCallback; this.client.Message += this.MessageCallback; this.client.Disconnection += this.DisconnectCallback; Log.Message("Try connecting to " + this.address); client.Connect(); }
public override void Apply(User user, RealmData realmData) { // We spawn the object with a DropPod Log.Message("Drop pod to spawn !"); Thing thing = realmData.FromRealmThing(realmThing); IntVec3 position = DropCellFinder.RandomDropSpot(); DropPodUtility.DropThingsNear(position, new Thing[] { thing }); Find.LetterStack.ReceiveLetter( "Ship pod", "A pod was sent from " + userFrom.name + " containing " + thing.Label, LetterType.Good, position ); }
public Pawn FromRealmAnimal(RealmData realmData) { PawnKindDef kindDef = DefDatabase <PawnKindDef> .GetNamed(kindDefName); Pawn pawn = (Pawn)ThingMaker.MakeThing(kindDef.race); pawn.kindDef = kindDef; pawn.SetFactionDirect(Faction.OfPlayer); PawnComponentsUtility.CreateInitialComponents(pawn); pawn.gender = gender; pawn.ageTracker.AgeBiologicalTicks = ageBiologicalTicks; pawn.ageTracker.AgeChronologicalTicks = ageChronologicalTicks; pawn.Name = new NameSingle(name); return(pawn); }
public override void Apply(User user, RealmData realmData) { string filteredName = TextHelper.StripRichText(name, TextHelper.SIZE); filteredName = TextHelper.Clamp(filteredName, User.MIN_NAME_LENGTH, User.MAX_NAME_LENGTH); // Is this nick available ? if (realmData.users.Any((u) => u.name == filteredName)) { realmData.NotifyPacket(user, new ErrorPacket { error = "Nickname " + filteredName + " is already taken" }); return; } user.name = filteredName; realmData.BroadcastPacket(new ChangeNicknameNotifyPacket { user = user, name = user.name }); }
private void MessageCallback(string data) { Packet packet = Packet.FromRaw(this.realmData, JObject.Parse(data)); Log.Message("Received packet from server: " + packet); if (packet is SynchronisationPacket) { // This is the first packet that we receive // It contains all the data of the server SynchronisationPacket syncPacket = (SynchronisationPacket)packet; this.realmData = syncPacket.realmData; this.currentUser = syncPacket.user; } else { packet.Apply(this.currentUser, this.realmData); } }
// Token: 0x0600000A RID: 10 RVA: 0x000020F0 File Offset: 0x000002F0 public override void Apply(User user, RealmData realmData) { var filteredName = TextHelper.StripRichText(name, "size"); filteredName = TextHelper.Clamp(filteredName, 4, 32); if (realmData.users.Any(u => u.name == filteredName)) { realmData.NotifyPacket(user, new ErrorPacket { error = "Nickname " + filteredName + " is already taken" }); return; } user.name = filteredName; realmData.BroadcastPacket(new ChangeNicknameNotifyPacket { user = user, name = user.name }); }
public override void Apply(User user, RealmData realmData) { Dialog_Confirm d = new Dialog_Confirm(error, () => { }); Find.WindowStack.Add(d); }
// Token: 0x06000005 RID: 5 RVA: 0x00002180 File Offset: 0x00000380 public void Disconnect() { client.Disconnect(); client = null; realmData = null; }
public override void Apply(User user, RealmData realmData) { // Since Authentification packets are special, they are handled in Programm.cs }
public override void Apply(User user, RealmData realmData) { realmData.ServerPostMessage(user, this.message); }