当前位置:网站首页>Unity websocket client

Unity websocket client

2022-07-07 10:49:00 HCC2017

be based on WebSocketSharp

public class WebSocketClient : MonoBehaviour
{

private string url = "ws://"

public WebSocket webSocket;

 private void Start()
    {
        Application.targetFrameRate = 60;
        vehicleProperties = new VehicleProperties();
        vehicleProperties.at_id.Add(carName);
        webSocket = Init(url);
        Register();
    }

 public bool ConnState(WebSocket ws)
         {
        if (ws == null)
            return false;

             if (ws.ReadyState==WebSocketState.Open)
             {
                return true;
             }
             return false;
         }

 private WebSocket Init(string url )
    {
    //   Debug.LogError(" initialization ");
        WebSocket ws= new WebSocket(url);
        ws.WaitTi

原网站

版权声明
本文为[HCC2017]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202130622491503.html