mirror of
https://gitlab1.ptb.de/waltem01/csharpsocketserver
synced 2024-02-04 23:19:43 +00:00
added on connect functionality
This commit is contained in:
parent
a054b0137c
commit
755f7a3639
|
@ -13,6 +13,7 @@ public static class Connection {
|
|||
public static string ipAddress;
|
||||
private static int listeners = 0;
|
||||
public static Action<Socket> disconnectMethod;
|
||||
public static Action<Socket> connectMethod;
|
||||
public static List<MessageEvent> messageEvents;
|
||||
|
||||
public static void Initialize(int _port=3000) {
|
||||
|
@ -21,6 +22,7 @@ public static class Connection {
|
|||
buffer = new byte[1024];
|
||||
messageEvents = new List<MessageEvent>();
|
||||
disconnectMethod = new Action<Socket>((other)=>{});
|
||||
connectMethod = new Action<Socket>((other)=>{});
|
||||
|
||||
// Get computers' ipv4 address
|
||||
ipAddress = "127.0.0.1";
|
||||
|
@ -120,6 +122,7 @@ public static class Connection {
|
|||
other.BeginReceive(buffer, 0, buffer.Length, SocketFlags.None, new AsyncCallback(ReceiveCallback), other);
|
||||
if (self == null)
|
||||
self = other;
|
||||
connectMethod.Invoke(other);
|
||||
}
|
||||
|
||||
// Handle sending messages
|
||||
|
|
Loading…
Reference in New Issue
Block a user