Send() public method

public Send ( int toClient = -1, int ignoreClient = -1 ) : void
toClient int
ignoreClient int
return void
Exemplo n.º 1
0
		internal static void SyncMods(int clientIndex) {
			var p = new ModPacket(MessageID.SyncMods);
			p.Write(AllowVanillaClients);

			var syncMods = ModLoader.LoadedMods.Where(mod => mod.Side == ModSide.Both).ToArray();
			p.Write(syncMods.Length);
			foreach (var mod in syncMods)
			{
				p.Write(mod.Name);
				p.Write(mod.Version.ToString());
				p.Write(mod.File.hash);
				p.Write(mod.File.ValidModBrowserSignature);
			}

			p.Send(clientIndex);
		}
Exemplo n.º 2
0
        internal static void SyncMods(int clientIndex)
        {
            var p = new ModPacket(MessageID.SyncMods);

            p.Write(AllowVanillaClients);

            var syncMods = ModLoader.Mods.Where(mod => mod.Side == ModSide.Both).ToArray();

            p.Write(syncMods.Length);
            foreach (var mod in syncMods)
            {
                p.Write(mod.Name);
                p.Write(mod.Version.ToString());
                p.Write(mod.File.hash);
                p.Write(mod.File.ValidModBrowserSignature);
            }

            p.Send(clientIndex);
        }
Exemplo n.º 3
0
        internal static void SyncMods(int clientIndex)
        {
            var p = new ModPacket(MessageID.SyncMods);

            p.Write(AllowVanillaClients);

            var syncMods = ModLoader.Mods.Where(mod => mod.Side == ModSide.Both).ToList();

            AddNoSyncDeps(syncMods);

            p.Write(syncMods.Count);
            foreach (var mod in syncMods)               // We only sync ServerSide configs for ModSide.Both. ModSide.Server can have
            {
                p.Write(mod.Name);
                p.Write(mod.Version.ToString());
                p.Write(mod.File.hash);
                p.Write(mod.File.ValidModBrowserSignature);
                var modConfigs = ConfigManager.Configs.SingleOrDefault(x => x.Key == mod).Value?.Where(x => x.Mode == ConfigScope.ServerSide);
                if (modConfigs == null)
                //if (modConfigs.Equals(default(List<ModConfig>)))
                {
                    p.Write(0);
                    Console.WriteLine($"No configs for {mod.Name}");
                }
                else
                {
                    p.Write(modConfigs.Count());
                    foreach (var config in modConfigs)
                    {
                        string json = JsonConvert.SerializeObject(config, ConfigManager.serializerSettingsCompact);
                        Console.WriteLine($"Sending Server Config {config.Name}: {json}");

                        p.Write(config.Name);
                        p.Write(json);
                    }
                }
            }

            p.Send(clientIndex);
        }
Exemplo n.º 4
0
        internal static void SyncMods(int clientIndex)
        {
            var p = new ModPacket(MessageID.SyncMods);

            p.Write(AllowVanillaClients);

            var syncMods = ModLoader.Mods.Where(mod => mod.Side == ModSide.Both).ToList();

            AddNoSyncDeps(syncMods);

            p.Write(syncMods.Count);
            foreach (var mod in syncMods)               // We only sync ServerSide configs for ModSide.Both. ModSide.Server can have
            {
                p.Write(mod.Name);
                p.Write(mod.Version.ToString());
                p.Write(mod.File.hash);
                p.Write(mod.File.ValidModBrowserSignature);
                SendServerConfigs(p, mod);
            }

            p.Send(clientIndex);
        }
Exemplo n.º 5
0
        internal static void SendMod(string modName, int toClient)
        {
            var mod  = ModLoader.GetMod(modName);
            var path = mod.File.path;
            var fs   = new FileStream(path, FileMode.Open);
            {            //send file length
                var p = new ModPacket(MessageID.ModFile);
                p.Write(mod.DisplayName);
                p.Write(fs.Length);
                p.Send(toClient);
            }

            var buf = new byte[CHUNK_SIZE];
            int count;

            while ((count = fs.Read(buf, 0, buf.Length)) > 0)
            {
                var p = new ModPacket(MessageID.ModFile, CHUNK_SIZE + 3);
                p.Write(buf, 0, count);
                p.Send(toClient);
            }

            fs.Close();
        }
Exemplo n.º 6
0
		internal static void SendNetIDs(int toClient) {
			var p = new ModPacket(MessageID.ModPacket);
			p.Write((short)-1);
			p.Write(netMods.Length);
			foreach (var mod in netMods)
				p.Write(mod.Name);

			p.Send(toClient);
		}
Exemplo n.º 7
0
		internal static void SendMod(string modName, int toClient) {
			var mod = ModLoader.GetMod(modName);
			var path = mod.File.path;
			var fs = new FileStream(path, FileMode.Open);
			{//send file length
				var p = new ModPacket(MessageID.ModFile);
				p.Write(mod.DisplayName);
				p.Write(fs.Length);
				p.Send(toClient);
			}
			
			var buf = new byte[CHUNK_SIZE];
			int count;
			while ((count = fs.Read(buf, 0, buf.Length)) > 0)
			{
				var p = new ModPacket(MessageID.ModFile, CHUNK_SIZE + 3);
				p.Write(buf, 0, count);
				p.Send(toClient);
			}

			fs.Close();
		}
Exemplo n.º 8
0
		private static void DownloadNextMod() {
			downloadingMod = downloadQueue.Dequeue();
			downloadingFile = null;

			var p = new ModPacket(MessageID.ModFile);
			p.Write(downloadingMod.name);
			p.Send();
		}
Exemplo n.º 9
0
		internal static void SendNetIDs(int toClient) {
			var p = new ModPacket(MessageID.ModPacket);
			p.Write((short)-1);
			p.Write(netMods.Length);
			foreach (var mod in netMods)
				p.Write(mod.Name);
			
			ItemLoader.WriteNetGlobalOrder(p);
			WorldHooks.WriteNetWorldOrder(p);

			p.Send(toClient);
		}