Advertisement
Guest User

Untitled

a guest
May 24th, 2015
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3. using System;
  4.  
  5. public class EchoTest : MonoBehaviour
  6. {
  7.  
  8. // Use this for initialization
  9. public IEnumerator StartSoket()
  10. {
  11. WebSocket w = new WebSocket(new Uri("ws://echo.websocket.org"));
  12. yield return StartCoroutine(w.Connect());
  13.  
  14. w.SendString("Hi there");
  15.  
  16. int i = 0;
  17. while (true)
  18. {
  19. string reply = w.RecvString();
  20. if (reply != null)
  21. {
  22. Debug.Log("Received: " + reply);
  23. w.SendString("Hi there" + i++);
  24. }
  25. if (w.Error != null)
  26. {
  27. Debug.LogError("Error: " + w.Error);
  28. break;
  29. }
  30. yield return 0;
  31. }
  32. w.Close();
  33. }
  34.  
  35. public IEnumerator ConnectWebSocketsss()
  36. {
  37. Debug.LogError("Error: " );
  38. yield return 0;
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement