54 lines
1.5 KiB
C#
54 lines
1.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using WebSocketSharp;
|
|
|
|
public class GMTool : MonoBehaviour
|
|
{
|
|
public enum ChatServer { Dev, Live }
|
|
enum ChatType { Connect, DisConnect, Chat, Notice, HotTime }
|
|
|
|
WebSocket ws;
|
|
Dictionary<ChatServer, List<string>> ws_url = new Dictionary<ChatServer, List<string>>();
|
|
|
|
public InputField[] inputs; // 0 공지사항, 1 핫타임
|
|
public ChatServer ConnectServer = ChatServer.Dev;
|
|
|
|
private void Awake()
|
|
{
|
|
ws_url.Add(ChatServer.Dev, new List<string>
|
|
{
|
|
"ws://ec2-3-34-145-11.ap-northeast-2.compute.amazonaws.com:5111", // 데브
|
|
});
|
|
|
|
ws_url.Add(ChatServer.Live, new List<string>
|
|
{
|
|
"ws://ec2-3-34-145-11.ap-northeast-2.compute.amazonaws.com:5112", // 라이브
|
|
});
|
|
|
|
}
|
|
|
|
public void Send_Notice()
|
|
{
|
|
for (int i = 0; i < ws_url[ConnectServer].Count; i++)
|
|
{
|
|
ws = new WebSocket(ws_url[ConnectServer][i]);
|
|
ws.Connect();
|
|
ws.Send(string.Format("{0}|{1}|{2}", ChatType.Notice, DateTime.Now, inputs[0].text));
|
|
ws.Close();
|
|
ws = null;
|
|
}
|
|
}
|
|
public void Send_HotTime()
|
|
{
|
|
for (int i = 0; i < ws_url[ConnectServer].Count; i++)
|
|
{
|
|
ws = new WebSocket(ws_url[ConnectServer][i]);
|
|
ws.Connect();
|
|
ws.Send(string.Format("{0}|{1}|{2}", ChatType.HotTime, DateTime.Now, inputs[1].text));
|
|
ws.Close();
|
|
ws = null;
|
|
}
|
|
}
|
|
} |