/// <summary> /// Initializes a new instance of the <see cref="ClientPacketHandler"/> class. /// </summary> /// <param name="networkSender">The socket sender.</param> /// <param name="screenManager">The <see cref="IScreenManager"/>.</param> /// <param name="dynamicEntityFactory">The <see cref="IDynamicEntityFactory"/> used to serialize /// <see cref="DynamicEntity"/>s.</param> /// <exception cref="ArgumentNullException"><paramref name="dynamicEntityFactory" /> is <c>null</c>.</exception> /// <exception cref="ArgumentNullException"><paramref name="screenManager" /> is <c>null</c>.</exception> /// <exception cref="ArgumentNullException"><paramref name="networkSender" /> is <c>null</c>.</exception> public ClientPacketHandler(INetworkSender networkSender, IScreenManager screenManager, IDynamicEntityFactory dynamicEntityFactory) { if (dynamicEntityFactory == null) { throw new ArgumentNullException("dynamicEntityFactory"); } if (screenManager == null) { throw new ArgumentNullException("screenManager"); } if (networkSender == null) { throw new ArgumentNullException("networkSender"); } _networkSender = networkSender; _dynamicEntityFactory = dynamicEntityFactory; _screenManager = screenManager; _peerTradeInfoHandler = new ClientPeerTradeInfoHandler(networkSender); _peerTradeInfoHandler.GameMessageCallback += PeerTradeInfoHandler_GameMessageCallback; _objGrabber = new ObjGrabber(this); }
/// <summary> /// Synchronizes the User's stat values to the client. /// </summary> public void UpdateClient(INetworkSender sendTo) { if (!_anyStatsChanged) { return; } // Check if any stat values have changed var statsToUpdate = _changedStats.GetChangedStats(); if (statsToUpdate.IsEmpty()) { return; } // Build a packet containing all the new stat values and send it to the user using (var pw = ServerPacket.GetWriter()) { foreach (var stat in statsToUpdate) { ServerPacket.UpdateStat(pw, stat, StatCollectionType); } sendTo.Send(pw, ServerMessageType.GUIUserStats); } _anyStatsChanged = false; }
/// <summary> /// Initializes a new instance of the <see cref="Inventory"/> class. /// </summary> /// <param name="socket">The <see cref="INetworkSender"/> to use to communicate with the server.</param> /// <exception cref="ArgumentNullException"><paramref name="socket" /> is <c>null</c>.</exception> public Inventory(INetworkSender socket) { if (socket == null) throw new ArgumentNullException("socket"); _socket = socket; }
/// <summary> /// Sends data to the <see cref="INetworkSender"/>. This method is thread-safe. /// </summary> /// <param name="sender">The <see cref="INetworkSender"/> to use to send the data.</param> /// <param name="message">GameMessage to send to the User.</param> /// <param name="messageType">The <see cref="ServerMessageType"/> to use for sending the <paramref name="message"/>.</param> /// <param name="parameters">Message parameters.</param> public static void Send(this INetworkSender sender, GameMessage message, ServerMessageType messageType, params object[] parameters) { using (var pw = ServerPacket.SendMessage(message, parameters)) { sender.Send(pw, messageType); } }
/// <summary> /// Initializes a new instance of the <see cref="ItemInfoRequesterBase{T}"/> class. /// </summary> /// <param name="socket">The socket.</param> /// <exception cref="ArgumentNullException"><paramref name="socket" /> is <c>null</c>.</exception> protected ItemInfoRequesterBase(INetworkSender socket) { if (socket == null) { throw new ArgumentNullException("socket"); } _socket = socket; }
/// <summary> /// Initializes a new instance of the <see cref="ClientPeerTradeInfoHandler"/> class. /// </summary> /// <param name="networkSender">The <see cref="INetworkSender"/> used to communicate with the server.</param> /// <exception cref="ArgumentNullException"><paramref name="networkSender"/> is null.</exception> public ClientPeerTradeInfoHandler(INetworkSender networkSender) { if (networkSender == null) { throw new ArgumentNullException("networkSender"); } NetworkSender = networkSender; }
/// <summary> /// Initializes a new instance of the <see cref="Inventory"/> class. /// </summary> /// <param name="socket">The <see cref="INetworkSender"/> to use to communicate with the server.</param> /// <exception cref="ArgumentNullException"><paramref name="socket" /> is <c>null</c>.</exception> public Inventory(INetworkSender socket) { if (socket == null) { throw new ArgumentNullException("socket"); } _socket = socket; }
public bool AddSession(WireFormat protocol, ref ISessionProvider provider, INetworkSender networkSender, out IMessageConsumer session) { if (Interlocked.Increment(ref activeSessionCount) <= 0) { session = null; return(false); } session = provider.GetSession(protocol, networkSender); return(activeSessions.TryAdd(session, default)); }
private void Initialize() { rtcpNetworkSender = new UdpSender(destinationEP, RtpSession.TimeToLive); threadRtcpSender = new Thread(new ThreadStart(SendThread)); threadRtcpSender.IsBackground = true; threadRtcpSender.Name = "RtcpSender"; threadRtcpSender.Start(); InitializePerformanceCounters(); }
public FasterKVServerSessionBase( INetworkSender networkSender, FasterKV <Key, Value> store, Functions functions, SessionVariableLengthStructSettings <Value, Input> sessionVariableLengthStructSettings, ParameterSerializer serializer) : base(networkSender) { session = store.For(new ServerKVFunctions <Key, Value, Input, Output, Functions>(functions, this)) .NewSession <ServerKVFunctions <Key, Value, Input, Output, Functions> >(sessionVariableLengthStructSettings: sessionVariableLengthStructSettings); this.serializer = serializer; }
/// <inheritdoc /> public virtual IMessageConsumer GetSession(WireFormat wireFormat, INetworkSender networkSender) { switch (wireFormat) { case WireFormat.WebSocket: return(new WebsocketServerSession <Key, Value, Input, Output, Functions, ParameterSerializer> (networkSender, store, GetFunctions(), serializer, kvBroker, broker)); default: return(new BinaryServerSession <Key, Value, Input, Output, Functions, ParameterSerializer> (networkSender, store, GetFunctions(), serializer, kvBroker, broker)); } }
/// <summary> /// Initializes a new instance of the <see cref="UserInfo"/> class. /// </summary> /// <param name="socket">The socket.</param> /// <exception cref="ArgumentNullException"><paramref name="socket" /> is <c>null</c>.</exception> public UserInfo(INetworkSender socket) { if (socket == null) throw new ArgumentNullException("socket"); _socket = socket; // Create the collections for tracking if quest requirements statuses _hasStartQuestRequirements = new HasQuestRequirementsTracker(SendHasQuestStartRequirements); _hasFinishQuestRequirements = new HasQuestRequirementsTracker(SendHasQuestFinishRequirements); // Create some other stuff _inventory = new Inventory(socket); _questInfo = new UserQuestInformationExtended(this); }
/// <summary> /// Handles synchronizing the paper-doll information to a single client. /// </summary> /// <param name="client">The client to send the information to</param> internal void SynchronizeBodyLayersTo(INetworkSender client) { // Get the values to send var bodiesToSend = _bodies.Where(x => x != null); if (bodiesToSend.Count() == 0) { return; } // Send the paper-doll information using (var pw = ServerPacket.SetCharacterPaperDoll(_character.MapEntityIndex, bodiesToSend)) { client.Send(pw, ServerMessageType.MapDynamicEntityProperty); } }
/// <summary> /// Initializes a new instance of the <see cref="UserInfo"/> class. /// </summary> /// <param name="socket">The socket.</param> /// <exception cref="ArgumentNullException"><paramref name="socket" /> is <c>null</c>.</exception> public UserInfo(INetworkSender socket) { if (socket == null) { throw new ArgumentNullException("socket"); } _socket = socket; // Create the collections for tracking if quest requirements statuses _hasStartQuestRequirements = new HasQuestRequirementsTracker(SendHasQuestStartRequirements); _hasFinishQuestRequirements = new HasQuestRequirementsTracker(SendHasQuestFinishRequirements); // Create some other stuff _inventory = new Inventory(socket); _questInfo = new UserQuestInformationExtended(this); }
/// <summary> /// Sends a list of guild member names and ranks to a <see cref="User"/>. /// </summary> /// <param name="user">The user to send the information to.</param> /// <param name="header">The heading to give the list.</param> /// <param name="members">The guild members and their ranks to include in the list.</param> static void SendGuildMemberList(INetworkSender user, string header, IEnumerable <GuildMemberNameRank> members) { // Build the string var sb = new StringBuilder(); sb.AppendLine(header); foreach (var member in members) { sb.AppendLine(string.Format("{0}: {1}", member.Name, member.Rank)); } // Send using (var pw = ServerPacket.Chat(sb.ToString())) { user.Send(pw, ServerMessageType.GUI); } }
/// <summary> /// Initializes a new instance of the <see cref="ClientPacketHandler"/> class. /// </summary> /// <param name="networkSender">The socket sender.</param> /// <param name="screenManager">The <see cref="IScreenManager"/>.</param> /// <param name="dynamicEntityFactory">The <see cref="IDynamicEntityFactory"/> used to serialize /// <see cref="DynamicEntity"/>s.</param> /// <exception cref="ArgumentNullException"><paramref name="dynamicEntityFactory" /> is <c>null</c>.</exception> /// <exception cref="ArgumentNullException"><paramref name="screenManager" /> is <c>null</c>.</exception> /// <exception cref="ArgumentNullException"><paramref name="networkSender" /> is <c>null</c>.</exception> public ClientPacketHandler(INetworkSender networkSender, IScreenManager screenManager, IDynamicEntityFactory dynamicEntityFactory) { if (dynamicEntityFactory == null) throw new ArgumentNullException("dynamicEntityFactory"); if (screenManager == null) throw new ArgumentNullException("screenManager"); if (networkSender == null) throw new ArgumentNullException("networkSender"); _networkSender = networkSender; _dynamicEntityFactory = dynamicEntityFactory; _screenManager = screenManager; _peerTradeInfoHandler = new ClientPeerTradeInfoHandler(networkSender); _peerTradeInfoHandler.GameMessageCallback += PeerTradeInfoHandler_GameMessageCallback; _objGrabber = new ObjGrabber(this); }
/// <summary> /// Sends data to the <see cref="INetworkSender"/>. This method is thread-safe. /// </summary> /// <param name="sender">The <see cref="INetworkSender"/> to use to send the data.</param> /// <param name="data">BitStream containing the data to send to the User.</param> /// <param name="messageType">The <see cref="ServerMessageType"/> to use for sending the <paramref name="data"/>.</param> public static void Send(this INetworkSender sender, BitStream data, ServerMessageType messageType) { if (!sender.IsConnected) { const string errmsg = "Send to `{0}` failed - not connected."; if (log.IsErrorEnabled) { log.ErrorFormat(errmsg, sender); } return; } NetDeliveryMethod method; int seqChannel; messageType.GetDeliveryMethod(out method, out seqChannel); sender.Send(data, method, seqChannel); }
public BinaryServerSession( INetworkSender networkSender, FasterKV <Key, Value> store, Functions functions, ParameterSerializer serializer, SubscribeKVBroker <Key, Value, Input, IKeyInputSerializer <Key, Input> > subscribeKVBroker, SubscribeBroker <Key, Value, IKeySerializer <Key> > subscribeBroker) : base(networkSender, store, functions, null, serializer) { this.subscribeKVBroker = subscribeKVBroker; this.subscribeBroker = subscribeBroker; readHead = 0; // Reserve minimum 4 bytes to send pending sequence number as output if (this.networkSender.GetMaxSizeSettings.MaxOutputSize < sizeof(int)) { this.networkSender.GetMaxSizeSettings.MaxOutputSize = sizeof(int); } }
public RemoteServerConnection(INetworkSender netSender) { _netSender = netSender; }
internal void EnableDiagnostics(IPEndPoint diagnosticServer) { diagnosticSender = new UdpSender(diagnosticServer, 64); }
private void InitializeNetwork() { rtpNetworkSender = new UdpSender(rtpSession.RtpEndPoint, rtpSession.TTL); }
public static void Send <T>(this INetworkSender connection, byte header, in T message, Reliability reliablity = Reliability.Reliable)
public RemoteExampleClientLobby(INetworkSender netSender) { _netSender = netSender; }
public RemoteExampleServerAuthenticator(INetworkSender netSender) { _netSender = netSender; }
public RemoteExampleServerMatch(INetworkSender netSender) { _netSender = netSender; }
/// <summary> /// Initializes a new instance of the <see cref="InventoryInfoRequester"/> class. /// </summary> /// <param name="inventory">The inventory.</param> /// <param name="socket">The socket.</param> public InventoryInfoRequester(Inventory inventory, INetworkSender socket) : base(socket) { Inventory = inventory; }
/// <summary> /// Sends a list of guild member names and ranks to a <see cref="User"/>. /// </summary> /// <param name="user">The user to send the information to.</param> /// <param name="header">The heading to give the list.</param> /// <param name="members">The guild members and their ranks to include in the list.</param> static void SendGuildMemberList(INetworkSender user, string header, IEnumerable<GuildMemberNameRank> members) { // Build the string var sb = new StringBuilder(); sb.AppendLine(header); foreach (var member in members) { sb.AppendLine(string.Format("{0}: {1}", member.Name, member.Rank)); } // Send using (var pw = ServerPacket.Chat(sb.ToString())) { user.Send(pw, ServerMessageType.GUI); } }
/// <summary> /// Sends data to the <see cref="INetworkSender"/>. This method is thread-safe. /// </summary> /// <param name="sender">The <see cref="INetworkSender"/> to use to send the data.</param> /// <param name="message">GameMessage to send to the User.</param> /// <param name="messageType">The <see cref="ServerMessageType"/> to use for sending the <paramref name="message"/>.</param> public static void Send(this INetworkSender sender, GameMessage message, ServerMessageType messageType) { sender.Send(message, messageType, null); }
/// <summary> /// Initializes a new instance of the <see cref="EquipmentInfoRequester"/> class. /// </summary> /// <param name="equipment">The equipment.</param> /// <param name="socket">The socket.</param> public EquipmentInfoRequester(UserEquipped equipment, INetworkSender socket) : base(socket) { Equipment = equipment; }
/// <summary> /// Create instance of session backed by given networkSender /// </summary> /// <param name="networkSender"></param> public ServerSessionBase(INetworkSender networkSender) { this.networkSender = networkSender; bytesRead = 0; }
public RemoteExampleClientMatch(INetworkSender netSender) { _netSender = netSender; }
public RemoteExampleServerLobby(INetworkSender netSender) { _netSender = netSender; }
/// <summary> /// Sends the paper-doll information for this <see cref="Character"/> to a specific client. /// </summary> /// <param name="client">The client to send this <see cref="Character"/>'s paper-doll information to.</param> public void SynchronizePaperdollTo(INetworkSender client) { _paperDoll.SynchronizeBodyLayersTo(client); }
/// <summary> /// Helper method to ensure packets are being sent with the correct headers /// when sending a message. /// /// The type T must be registered in MessageHandlers before this method can be /// used. /// </summary> protected void Send <T>(INetworkSender sender, in T msg,