63 lines
1.4 KiB
C#
63 lines
1.4 KiB
C#
using RData;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Threading;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class CreateRoomController : MonoBehaviour
|
|
{
|
|
public string serverIP;
|
|
public int port;
|
|
public InputField roomField;
|
|
public bool isLinkAgain = false;
|
|
private async void Awake()
|
|
{
|
|
try
|
|
{
|
|
isLinkAgain = true;
|
|
await SyncCreateRoom.StartLinkTCPServer(serverIP, port);
|
|
}
|
|
catch (System.Exception e)
|
|
{
|
|
if (isLinkAgain)
|
|
{
|
|
Awake();
|
|
}
|
|
Debug.Log(e.ToString());
|
|
}
|
|
|
|
}
|
|
// Start is called before the first frame update
|
|
private void Start()
|
|
{
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
|
|
}
|
|
|
|
public async void OnCreateRoom()
|
|
{
|
|
RoomData roomData = new RoomData();
|
|
roomData.Name = roomField.text;
|
|
roomData.ThinkingData = "ttttt";
|
|
roomData.MissionModel = "qqqqqqqq";
|
|
string roomDataTemp = JsonUtility.ToJson(roomData);
|
|
SyncCreateRoom.CreateRoom(roomDataTemp);
|
|
await SyncCreateRoom.ReciveMessage();
|
|
if (SyncCreateRoom.serverReturnValue.Equals("创建成功"))
|
|
{
|
|
Debug.Log("dsds ");
|
|
}
|
|
}
|
|
|
|
private void OnDisable()
|
|
{
|
|
SyncCreateRoom.CloseClint();
|
|
isLinkAgain = false;
|
|
}
|
|
}
|