Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Net;
- using System.Threading.Tasks;
- using System.Net.Sockets;
- using System.Timers;
- using System.Text;
- namespace Roleplay_Flash_Server.assets.communication.client.events
- {
- class pingIntervalEvent
- {
- private static string prefix = "[communication->client->events->pingIntervalEvent.cs] ";
- public static void init(TcpClient socket)
- {
- Byte[] replyData = System.Text.Encoding.ASCII.GetBytes("PingIntervalEvent{}");
- socket.GetStream().Write(replyData, 0, replyData.Length);
- string clientIP = ((IPEndPoint)socket.Client.RemoteEndPoint).Address.ToString();
- string clientPort = ((IPEndPoint)socket.Client.RemoteEndPoint).Port.ToString();
- Console.WriteLine(prefix + "Ping Interval Event was ran for {#" + "?" + "}, {" + clientIP + ":" + clientPort + "}.");
- if (socket.Connected == false)
- {
- Console.WriteLine(prefix + "Ping Interval Event has responded as a failure for {#" + "?" + "}, {" + clientIP + ":" + clientPort + "}; Aborting connection...");
- socket.Close();
- }
- else
- Console.WriteLine(prefix + "Ping Interval Event has responded as a success for {#" + "?" + "}, {" + clientIP + ":" + clientPort + "}.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment