public ClientEventSink(NetClient client, Simple.Proxy proxy) { m_client = client; m_simpleProxy = proxy; IsConnectWaiting = true; IsConnected = false; GroupID = HostID.HostID_None; m_client.JoinServerCompleteHandler = OnJoinServerComplete; m_client.LeaveServerHandler = OnLeaveServer; m_client.P2PMemberJoinHandler = OnP2PMemberJoin; m_client.P2PMemberLeaveHandler = OnP2PMemberLeave; m_client.ErrorHandler = OnError; m_client.WarningHandler = OnWarning; m_client.ExceptionHandler = OnException; m_client.InformationHandler = OnInformation; m_client.NoRmiProcessedHandler = OnNoRmiProcessed; m_client.ChangeServerUdpStateHandler = OnChangeServerUdp; m_client.ReceivedUserMessageHandler = OnReceiveUserMessage; }
// Use this for initialization IEnumerator Start() { m_client = new NetClient(); m_connectionParam = new NetConnectionParam(); m_simpleProxy = new Simple.Proxy(); m_simpleStub = new Simple.Stub(); m_eventSink = new ClientEventSink(m_client, m_simpleProxy); m_myClass = new SimpleUnity.MyClass(); m_simpleStub.ShowChat = ShowChat; m_simpleStub.SystemChat = SystemChat; m_simpleStub.P2PChat = P2PChat; m_client.AttachProxy(m_simpleProxy); m_client.AttachStub(m_simpleStub); m_connectionParam.protocolVersion = new Nettention.Proud.Guid(); m_connectionParam.protocolVersion.Set(SimpleUnity.Vars.Version); // 웹플레이어로 접속시에는 localhost 가 아닌 IP를 써주어야 함. m_connectionParam.serverIP = "localhost"; m_connectionParam.serverPort = (ushort)SimpleUnity.Vars.ServerPort; m_screenWidth = Screen.width; // 현재 화면의 가로 값 셋팅. m_screenHeight = Screen.height; // 현재 화면의 세로 값 셋팅. m_screenOneW = m_screenWidth / 5; // 현재 화면의 가로를 5로 나눈값으로 셋팅. m_screenOneH = m_screenHeight / 10; // 현재 화면의 세로를 10으로 나눈 값으로 셋팅. m_height = m_screenOneH * 7; // 채팅창 높이 초기화. m_scrollHeight = 0; LogList = new List <string>(); #if UNITY_WEBPLAYER Security.PrefetchSocketPolicy(m_connectionParam.serverIP, (int)m_connectionParam.serverPort); #endif if (m_client.Connect(m_connectionParam) == false) { print("m_client failed to connect to server!!"); } else { long time = System.DateTime.Now.Ticks; long currentTime; while (m_eventSink.IsConnectWaiting) { // 코루틴을 이용해 m_WaitTime 동안 대기. yield return(new WaitForSeconds(m_WaitTime)); m_client.FrameMove(); currentTime = System.DateTime.Now.Ticks; // ticks 의 1초는 10000000 if (currentTime - time > 100000000) { break; } } m_myClass.a = 1; m_myClass.b = 1.5f; m_myClass.c = 3.141592; // List혹은 Dictionary를 Rmi인자로 사용이 가능합니다. m_listData = new List <int>(); m_listData.Add(4); m_listData.Add(5); m_dictionaryData = new Dictionary <int, float>(); m_dictionaryData.Add(1, 1.5f); m_dictionaryData.Add(2, 3.1f); m_blockData = new ByteArray(); for (int i = 0; i < 100; ++i) { m_blockData.Add((byte)i); } m_simpleProxy.Chat(HostID.HostID_Server, RmiContext.ReliableSend, "우갸갸갸갸갹.", 22, 22.33f); } }