hi guys
im trying to create a multiplayer game with dedicated server and now having problem with websocket sharp
i just want to change a text value on scene when get a message from server and show the message on scene
please let me know whats wrong with my code
using UnityEngine;
using WebSocketSharp;
using UnityEngine.UI;
public class WsClient : MonoBehaviour
{
WebSocket ws;
string tmpText;
public TextChanger other;
JsonObject jj = new JsonObject();
private void Start()
{
other = FindObjectOfType();
ws = new WebSocket(“ws://localhost:8080”);
ws.OnOpen += (sender, e) =>
{
Debug.Log(“Connected”);
};
ws.OnError += (sender, err) =>
{
Debug.Log("error " + err.Message);
Debug.Log(“ERR”);
};
ws.OnMessage += (sender, e) =>
{
jj = JsonUtility.FromJson(e.Data);
Debug.Log(“TOP”);
other.TXTChanger(e.Data);
Debug.Log(“DOWN”);
};
ws.Connect();
}
private void Update()
{
if (ws == null)
{
return;
}
if (Input.GetKeyDown(KeyCode.Space))
{
ws.Send(“Hello”);
}
}
}
i see TOP , error message and ERR but Debug.Log(“DOWN”) didnt executed
this is error message :
error An error has occurred during an OnMessage event.
UnityEngine.Debug:Log (object)
WsClient/<>c:b__7_1 (object,WebSocketSharp.ErrorEventArgs) (at Assets/WsClient.cs:27)
WebSocketSharp.Ext:Emit<WebSocketSharp.ErrorEventArgs> (System.EventHandler`1<WebSocketSharp.ErrorEventArgs>,object,WebSocketSharp.ErrorEventArgs)
WebSocketSharp.WebSocket:error (string,System.Exception)
WebSocketSharp.WebSocket:messagec (WebSocketSharp.MessageEventArgs)
WebSocketSharp.WebSocket:message ()
WebSocketSharp.WebSocket/<>c__DisplayClass176_0:b__1 (WebSocketSharp.WebSocketFrame)
WebSocketSharp.WebSocketFrame/<>c__DisplayClass83_0:b__3 (WebSocketSharp.WebSocketFrame)
WebSocketSharp.WebSocketFrame/<>c__DisplayClass77_0:b__0 (byte[ ])
WebSocketSharp.Ext/<>c__DisplayClass48_0:b__0 (System.IAsyncResult)
System.Threading._ThreadPoolWaitCallback:PerformWaitCallback ()