//Configure the SDK manually public void Configure(string host, int port, string accessToken, Action <int> OnPlayerConnect, Action <int> OnPlayerDisconnect, Action <bool> OnReady, Action <RTPacket> OnPacket) { m_OnPlayerConnect = OnPlayerConnect; m_OnPlayerDisconnect = OnPlayerDisconnect; m_OnReady = OnReady; m_OnPacket = OnPacket; #if UNITY_WEBGL && !UNITY_EDITOR lastSessionId++; currSessionId = lastSessionId; GSCreateRTSession(instance.name, currSessionId, accessToken, host, port); #else if (session != null) { session.Stop(); } session = GameSparksRT .SessionBuilder() .SetHost(host) .SetPort(port) .SetConnectToken(accessToken) .SetListener(this) .Build(); #endif }
//Configure the SDK manually public void Configure(string host, int port, string accessToken, Action <int> OnPlayerConnect, Action <int> OnPlayerDisconnect, Action <bool> OnReady, Action <RTPacket> OnPacket) { m_OnPlayerConnect = OnPlayerConnect; m_OnPlayerDisconnect = OnPlayerDisconnect; m_OnReady = OnReady; m_OnPacket = OnPacket; if (session != null) { session.Stop(); } session = GameSparksRT .SessionBuilder() .SetHost(host) .SetPort(port) .SetConnectToken(accessToken) .SetListener(this) .Build(); }
//The method to use to send data to a session. public int SendRTDataAndBytes(int opCode, GameSparksRT.DeliveryIntent deliveryIntent, ArraySegment<byte> unstructuredData, RTData structuredData, params int[] targetPlayers) { if(session != null){ return session.SendRTDataAndBytes(opCode, deliveryIntent, unstructuredData, structuredData, targetPlayers); } return -1; }
//The method to use to send data to a session. public int SendData(int opCode, GameSparksRT.DeliveryIntent deliveryIntent, RTData structuredData, params int[] targetPlayers) { if(session != null){ return session.SendRTData(opCode, deliveryIntent, structuredData, targetPlayers); } return -1; }