CotpServerOpenAsync Method (Byte, ServiceClientAsyncIPacketIOService) |
Namespace: Demo3D.Net.Protocols
public static Task<ServerSocket> OpenAsync( byte[] tsap, ServiceClientAsync<IPacketIOService> serviceConnection )
// Start a new server, calling ServiceConnectionAsync on every connection established. public async Task StartServerAsync(string tsap) { await CotpServer.OpenAsync(tsap, ServiceConnectionAsync); } // Services a client connection. async Task ServiceConnectionAsync(ServerClient<IPacketIOService> socket) { Logger.Log("Connection from " + socket.Address); // Simple server loops forever receiving messages and printing them to the log. for (;;) { // Read a packet from the client. using (var packet = await socket.IO.ReadAsync()) { var message = packet.ReadString(); Logger.Log("Message received: " + message); } } }