Skip to content

Commit

Permalink
Update 2.2
Browse files Browse the repository at this point in the history
Added information from which ip the request was sent
  • Loading branch information
danrom11 committed Jan 22, 2021
1 parent 1633c52 commit a57751a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
4 changes: 2 additions & 2 deletions Application-Connector.deps.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"targets": {
".NETStandard,Version=v2.0": {},
".NETStandard,Version=v2.0/": {
"Application-Connector/2.1": {
"Application-Connector/2.2": {
"dependencies": {
"NETStandard.Library": "2.0.3"
},
Expand All @@ -24,7 +24,7 @@
}
},
"libraries": {
"Application-Connector/2.1": {
"Application-Connector/2.2": {
"type": "project",
"serviceable": false,
"sha512": ""
Expand Down
Binary file modified Application-Connector.dll
Binary file not shown.
Binary file modified Application-Connector.pdb
Binary file not shown.
17 changes: 9 additions & 8 deletions Connector.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.IO.MemoryMappedFiles;
using System.Linq.Expressions;
using System.Net;
using System.Net.Sockets;
using System.Text;
Expand Down Expand Up @@ -115,7 +116,7 @@ public void ServerStart()
SetupServer();
}

public static void ServerClose()
public void ServerClose()
{
foreach (Socket socket in clientSockets)
{
Expand Down Expand Up @@ -181,7 +182,8 @@ private void ReceiveCallback(IAsyncResult AR)
byte[] recBuf = new byte[received];
Array.Copy(buffer, recBuf, received);
string text = Encoding.ASCII.GetString(recBuf);
Console.WriteLine("Received Text: " + text);
Console.WriteLine(text);
text = text.Substring(text.IndexOf("->") + 3);

if (text.Contains("@"))
{
Expand Down Expand Up @@ -236,7 +238,6 @@ private string StandardCommands(string command)
sendMsg = true;
return "EX";
}
Console.WriteLine("Standard Commands -> The command is missing");
return "Standard Commands -> The command is missing";
}

Expand Down Expand Up @@ -275,13 +276,13 @@ private void ConnectToServer()
}
}

// Console.Clear();
// Console.Clear();
//Console.WriteLine("Connected");
}

public string Request(string text)
{
SendString(text);
SendString(text, _IPAdrees);
return ReceiveResponse();
}

Expand All @@ -290,7 +291,7 @@ public string Request(string text)
/// </summary>
public void ClientDisconnect()
{
SendString("@exit");
SendString("@exit", _IPAdrees);
ClientSocket.Shutdown(SocketShutdown.Both);
ClientSocket.Close();
//Environment.Exit(0);
Expand All @@ -299,9 +300,9 @@ public void ClientDisconnect()
/// <summary>
/// Sends a string to the server with ASCII encoding.
/// </summary>
private static void SendString(string text)
private static void SendString(string text, IPAddress ipClient)
{
byte[] buffer = Encoding.ASCII.GetBytes(text);
byte[] buffer = Encoding.ASCII.GetBytes(Convert.ToString(ipClient) + " -> " + text);
ClientSocket.Send(buffer, 0, buffer.Length, SocketFlags.None);
}

Expand Down

0 comments on commit a57751a

Please sign in to comment.