/// <summary> /// Sends the specified message. /// </summary> internal static void Send(int serviceNodeType, int serviceNodeId, NetMessage message, byte[] sessionId = null) { NetSocket destinationSocket = NetManager.GetServiceNodeEndPoint(serviceNodeType, serviceNodeId); if (destinationSocket != null) { NetMessaging.Send(destinationSocket, message, sessionId); } }
/// <summary> /// Sends the specified message. /// </summary> internal static void Send(NetSocket destinationSocket, NetMessage message, byte[] sessionId = null) { if (destinationSocket == null) { throw new ArgumentNullException("destinationSocket"); } message.SetServiceNodeType(ServiceCore.ServiceNodeType); message.SetServiceNodeId(ServiceCore.ServiceNodeId); message.SetSessionId(sessionId); message.Encode(); NetMessaging._messageHandler.Send(destinationSocket, new NetPacket(message)); }
/// <summary> /// Gets a random <see cref="NetSocket" /> instance. /// </summary> public static NetSocket GetRandomEndPoint(int serviceNodeType) { if (serviceNodeType > -1 && serviceNodeType < NetManager._endPoints.Length) { if (NetManager._endPoints[serviceNodeType].Count != 0) { NetSocket socket = NetManager._endPoints[serviceNodeType][NetManager._scrambler[serviceNodeType]]; NetManager._scrambler[serviceNodeType] = (NetManager._scrambler[serviceNodeType] + 1) % NetManager._endPoints[serviceNodeType].Count; return(socket); } } else { Logging.Warning("NetManager::getRandomEndPoint serviceNodeType out of bands " + serviceNodeType + "/" + NetManager._endPoints.Length); } return(null); }