public override void onserverrecieve(NetIncomingMessage message) { Packet_MatrixRename packet = PacketWriter.write <Packet_MatrixRename>(NetEndpoint.SERVER); packet.outgoingmessage.Write(message.ReadInt32()); packet.outgoingmessage.Write(message.ReadString()); packet.send(); base.onserverrecieve(message); }
public override void onserverrecieve(NetIncomingMessage message) { var chat = PacketWriter.write <Packet_Chat>(NetEndpoint.SERVER); chat.outgoingmessage.Write(message.ReadString()); chat.outgoingmessage.Write(message.ReadString()); chat.send(); base.onserverrecieve(message); }
public override void onserverrecieve(NetIncomingMessage message) { Server.print("info", "Recieved qb packet"); NetConnection senderconnection = message.SenderConnection; var packet = PacketWriter.write <Packet_QbImported>(NetEndpoint.SERVER); packet.outgoingmessage.Write(message.Data); packet.send(); base.onserverrecieve(message); }
public static void loadqbnetworking(string path) { if (Client.net != null && Client.net.ConnectionsCount == 0) { Client.print("error", "Error : loadqbnetworking - is meant for network loading of files. Connect your client to a server before running this command, or try using \"loadqb\""); return; } Client.OpenGLContextThread.Add(() => { StopwatchUtil.startclient("internalqbread", "Begin Qb Read"); ImporterQb importer = new ImporterQb(); QbModel model = importer._read(path); StopwatchUtil.stopclient("internalqbread", "End Qb Read"); StopwatchUtil.startclient("clientwriteqbpacket", "Begin Qb Packet Write"); var packet = PacketWriter.write <Packet_QbImported>(NetEndpoint.CLIENT); packet.write(model); packet.send(); StopwatchUtil.stopclient("clientwriteqbpacket", "End qb Packet Write"); }); }
static void Main(string[] args) { Console.Title = "StoneVox 3D"; string version = Assembly.GetExecutingAssembly().GetName().Version.ToString(); string Title = String.Format("StoneVox 3D Voxel Modeler for StoneHearth : build {0}", version.Split('.').Last()); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine(Title); Console.WriteLine(""); Console.ForegroundColor = ConsoleColor.White; if (args.Length == 0) { args = new string[] { "/startclient" }; } Regex r = new Regex("(?<match>[^\\s\"]+)|(?<match>\"[^\"]*\")"); var cmds = typeof(ConsoleCommands).GetMethods(BindingFlags.Static | BindingFlags.Public); for (int i = 0; i < args.Length; i++) { string arg = args[i]; while (true) { if (i + 1 < args.Length && !args[i + 1].Contains('/')) { arg += " " + args[i + 1]; i++; } else { MatchCollection matches = r.Matches(arg); List <string> splits = new List <string>(); foreach (Match m in matches) { splits.Add(m.Value.Replace("\"", "")); } int argcount = splits.Count; foreach (var c in cmds) { ConsoleCommand command = (ConsoleCommand)c.GetCustomAttribute(typeof(ConsoleCommand)); if (arg.Contains(command.name) && argcount - 1 == command.argcount) { List <object> cmdargs = new List <object>(); if (argcount > 1) { for (int ii = 1; ii < argcount; ii++) { cmdargs.Add(splits[ii]); } } c.Invoke(null, cmdargs.ToArray()); } } break; } } } string read = ""; while (true) { ConsoleKeyInfo ki = Console.ReadKey(true); if ((ki.Key == ConsoleKey.V) && (ki.Modifiers == ConsoleModifiers.Control)) { string s = Clipboard.GetText(); if (!string.IsNullOrEmpty(s)) { s = s.Replace("\r", "").Replace("\n", ""); } Console.Write(s); read += s; } else if (ki.Key == ConsoleKey.Enter) { Console.Write("\r\n"); read = read.ToLower(); read = read.Trim(); if (!string.IsNullOrEmpty(read) && read[0] == '/') { MatchCollection matches = r.Matches(read); List <string> splits = new List <string>(); foreach (Match m in matches) { splits.Add(m.Value.Replace("\"", "")); } int argcount = splits.Count; foreach (var c in cmds) { ConsoleCommand command = (ConsoleCommand)c.GetCustomAttribute(typeof(ConsoleCommand)); if (read.Contains(command.name) && argcount - 1 == command.argcount) { List <object> cmdargs = new List <object>(); if (argcount > 1) { for (int i = 1; i < argcount; i++) { cmdargs.Add(splits[i]); } } c.Invoke(null, cmdargs.ToArray()); } } } else { var packet = PacketWriter.write <Packet_Chat>(NetEndpoint.CLIENT); packet.outgoingmessage.Write(Client.ID); packet.outgoingmessage.Write(read); packet.send(); } read = ""; } else if (ki.Key == ConsoleKey.Backspace) { if (read.Length > 0) { read = read.Remove(read.Length - 1); } Console.Write("\b \b"); } else { read += ki.KeyChar; Console.Write(ki.KeyChar); if (read == "/exit") { break; } } } Server.net?.Shutdown("shutting down"); Client.net?.Shutdown("shutting down"); Client.window?.Close(); }