guacamole in progress
This commit is contained in:
40
CollabVM/Server/CollabVMGuacamoleServer.cs
Normal file
40
CollabVM/Server/CollabVMGuacamoleServer.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using System.Net;
|
||||
using System.Net.WebSockets;
|
||||
using System.Text;
|
||||
|
||||
namespace CollabVM.Server
|
||||
{
|
||||
public class CollabVMGuacamoleServer
|
||||
{
|
||||
public async void HandleSocket(WebSocket ws, IPEndPoint remote)
|
||||
{
|
||||
Console.Error.WriteLine("new WebSocket, who dis?");
|
||||
#warning we probably don't need this much
|
||||
Byte[] buf = new Byte[1024];
|
||||
try
|
||||
{
|
||||
while (ws.State == WebSocketState.Open)
|
||||
{
|
||||
#warning probably needs a real ctoken
|
||||
WebSocketReceiveResult recResult = await ws.ReceiveAsync(new ArraySegment<Byte>(buf), CancellationToken.None);
|
||||
Console.Error.WriteLine(recResult.MessageType);
|
||||
switch (recResult.MessageType)
|
||||
{
|
||||
case WebSocketMessageType.Close:
|
||||
await ws.CloseAsync(WebSocketCloseStatus.NormalClosure, "", CancellationToken.None);
|
||||
break;
|
||||
case WebSocketMessageType.Text:
|
||||
String msg = Encoding.UTF8.GetString(buf, 0, recResult.Count);
|
||||
Console.Error.WriteLine(msg);
|
||||
break;
|
||||
default:
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
} finally
|
||||
{
|
||||
ws.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user