Unity3D - Websockets and C#
We have a light weight receive function in our client code, we use json for our messaging bus. Unity3d crashes whenever an attempt to receive on the established socket, anyone know how to test a web socket connection to verify that it has data/is readable? :
public Hashtable RecvMsg()
{
lock(locker)
{
string recvMsg;
recvMsg = webSocket.Recv();
Hashtable message = new Hashtable();
message = JsonMapper.ToObject
Hashtable result = new Hashtable();
if(message["messageStatus"].ToString() == "True")
{
result = JsonMapper.ToObject
return result;
}
else
{
Debug.Log(message["messageError"].ToString());
return null;
}
}
/*
lock(locker) {
string msg = webSocket.Recv();
if(msg != null)
{
//string msg = opSec.DecryptText(iMsg, iKey, iIV);
Hashtable data = new Hashtable();
data = JsonMapper.ToObject
queue.Enqueue(data);
print("msg received");
}
}
*/
}
"You work that you may keep pace with the earth and the soul of the earth. For to be idle is to become a stranger unto the seasons, and to step out of life's procession, that marches in majesty and proud submission towards the infinite."
-Kahlil Gibran excerpt from The Prophet.
- Login or join to post comments
Post to Twitter

