ServerExample.cs 778 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. public class ServerExample : MonoBehaviour {
  6. //public Text text_ip;
  7. //public InputField text_send;
  8. //public Text text_receive;
  9. private Tcp_Server ts;
  10. // Use this for initialization
  11. void Start () {
  12. ts = GetComponent<Tcp_Server> ();
  13. //Debug.Log (Tcp_Util.GetAddressIP () + "");
  14. //text_ip.text = Tcp_Util.GetAddressIP () + "";
  15. onStartUp ();
  16. }
  17. // Update is called once per frame
  18. void Update()
  19. {
  20. }
  21. public void onStartUp()
  22. {
  23. ts.StartUp ();
  24. }
  25. public void send(MessageData msg)
  26. {
  27. byte[] bytes = Tcp_Util.MessageToBuffer (msg);
  28. //byte[] bytes = Tcp_Util.StringToBytes (text_send.text);
  29. //text_send.text = "";
  30. ts.SendAll (bytes);
  31. }
  32. }