Pudge 24 Posted December 28, 2021 Share Posted December 28, 2021 Hello, @Droidz, there is an urgent need to control bots on two or more different machines, in wrobot have api API robotManager.Helpful.Var that allows you to create variables for communication within one bot program,I know that bots can read variables from an xml document on one computer to communicate, but how to do something like that so that bots on different PCs can transfer information to each other is not yet clear to me. It would be cool if you add such an api you can add or suggest how you can implement a variable so that bots can read it from different computer machines. Link to comment https://wrobot.eu/forums/topic/13806-global-variable-associated-with-the-license-key/ Share on other sites More sharing options...
Pudge 24 Posted December 28, 2021 Author Share Posted December 28, 2021 2 hours ago, Sye24 said: i think the safest way is to build your own server / client to talk between each other. Yes, but it requires a lot of programming knowledge Link to comment https://wrobot.eu/forums/topic/13806-global-variable-associated-with-the-license-key/#findComment-64440 Share on other sites More sharing options...
Droidz 2738 Posted December 28, 2021 Share Posted December 28, 2021 Hi, I wrote few time ago sample HTTP server plugin: Test server http.cs using System.Net; using System.Text; using System.Threading.Tasks; using robotManager.Helpful; using wManager.Wow.Helpers; using wManager.Wow.ObjectManager; public class Main : wManager.Plugin.IPlugin { /* Samples: http://localhost:8000/name http://localhost:8000/jump http://localhost:8000/pos http://localhost:8000/runlua?code=print(%22test%20from%20web%22) */ private readonly bool _debugLog = true; private HttpListener _listener; private readonly string _url = "http://localhost:8000/"; private int _requestCount; private bool _runServer; public void Initialize() { // Create a Http server and start listening for incoming connections _listener = new HttpListener(); _listener.Prefixes.Add(_url); _listener.Start(); if (_debugLog) Logging.WriteDebug("Listening for connections on " + _url); // Handle requests var listenTask = HandleIncomingConnections(); listenTask.GetAwaiter().GetResult(); } public void Dispose() { if (_listener != null) { _runServer = false; _listener.Close(); _listener = null; } } public void Settings() { } private async Task HandleIncomingConnections() { _runServer = true; // While a user hasn't visited the `shutdown` url, keep on handling requests while (_runServer) { // Will wait here until we hear from a connection var ctx = await _listener.GetContextAsync(); // Peel out the requests and response objects var req = ctx.Request; var resp = ctx.Response; // Print out some info about the request if (_debugLog) { Logging.WriteDebug("Request #: " + ++_requestCount); Logging.WriteDebug(req.Url.ToString()); Logging.WriteDebug(req.HttpMethod); Logging.WriteDebug(req.UserHostName); Logging.WriteDebug(req.UserAgent); Logging.WriteDebug(req.Url.AbsolutePath); } var content = string.Empty; // Parse if (req.Url.AbsolutePath == "/name") { content = ObjectManager.Me.Name; } else if (req.Url.AbsolutePath == "/jump") { Move.JumpOrAscend(); content = "done"; } else if (req.Url.AbsolutePath == "/pos") { content = ObjectManager.Me.Position.ToStringXml(); } else if (req.Url.AbsolutePath.StartsWith("/runlua")) { //var r = System.Web.HttpUtility.ParseQueryString(req.Url.Query).Get("code"); var r = req.QueryString["code"]; if (!string.IsNullOrWhiteSpace(r)) { Lua.LuaDoString(r); content = "ok"; } else content = "failed"; } // Write the response info byte[] data = Encoding.UTF8.GetBytes(content); resp.ContentType = "text/html"; resp.ContentEncoding = Encoding.UTF8; resp.ContentLength64 = data.LongLength; // Write out to the response stream (asynchronously), then close it await resp.OutputStream.WriteAsync(data, 0, data.Length); resp.Close(); } } } You can use one port by bot. But in any case what you want to do require programming knowledge. You can also create one server with API type REST to store data (with C# or more easy tools like python or nodejs), and use this API with bot plugin. You have a lot of possibility, but I can't add it to the bot API. Pudge 1 Link to comment https://wrobot.eu/forums/topic/13806-global-variable-associated-with-the-license-key/#findComment-64441 Share on other sites More sharing options...
Pudge 24 Posted December 29, 2021 Author Share Posted December 29, 2021 8 hours ago, Sye24 said: http://csharp.net-informations.com/communications/csharp-chat-server-programming.htm thanks for the help, I will study this Link to comment https://wrobot.eu/forums/topic/13806-global-variable-associated-with-the-license-key/#findComment-64447 Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now