/// <summary> /// Creates a new <see cref="NetClientReceiver"/> instance. /// </summary> /// <param name="client">Client.</param> public NetClientReceiver(INetClient client) : base(client.PacketProcessor) { this._client = client; this._socketAsyncEvent = new SocketAsyncEventArgs(); this._socketAsyncEvent.Completed += this.OnCompleted; }
public LidgrenClientNetworkSession(INetClient netClient, ILoggerFactory loggerFactory) { _netClient = netClient; _logger = loggerFactory.GetLogger(this.GetType()); ClientDisconnected += (obj, args) => _logger.Info("ZAK HERE: Client disconnected"); }
public RPCEvent(INetClient client, NetworkEvent netEvent, BSONObject bson, String methodName) { this._client = client; this._netEvent = netEvent; this._bson = bson; this._methodName = methodName; }
/// <summary> /// Fills the settings. /// </summary> /// <param name="client">The client.</param> /// <param name="property">The property.</param> public void Configure(INetClient client, PropertyInfo property) { if (BaseUri == null) { BaseUri = property.GetCustomAttributes <BaseUriAttribute>(true)?.FirstOrDefault()?.BaseUri; } if (BaseUri == null) { BaseUri = client.GetType().GetCustomAttributes <BaseUriAttribute>(true)?.FirstOrDefault()?.BaseUri; } if (SerializerSettings == null) { SerializerSettings = property.GetCustomAttributes <SerializerSettingsAttribute>(true)?.FirstOrDefault()?.SerializerSettings; } if (SerializerSettings == null) { SerializerSettings = client.GetType().GetCustomAttributes <SerializerSettingsAttribute>(true)?.FirstOrDefault()?.SerializerSettings; } var routes = property.GetCustomAttributes <RouteAttribute>(true)?.Select(attribute => attribute.Route); if (routes != null) { foreach (var route in routes) { Routes.Add(route); } } }
public void ReceiveEvent(INetClient client, NetworkEvent netEvent, BSONObject bson) { switch (netEvent) { case NetworkEvent.ClientUpdate: if (!createFromNetworkEvent(client, netEvent, bson).isCanceled) { NetObjectManager.Obj.UpdateObjects(bson); } break; case NetworkEvent.RPC: if (!createEventFromNetworkRPCEvent(client, netEvent, bson).isCanceled) { RPCManager.HandleReceiveRPC(client, bson); } break; case NetworkEvent.RPCResponse: if (!createFromNetworkResponseEvent(client, netEvent, bson).isCanceled) { RPCManager.HandleQueryResponse(bson); } break; } }
public IEnumerator AsyncGet(string url, INetClient client, TokenData token) { UnityWebRequest www; using (www = UnityWebRequest.Get(url)) { www.SetRequestHeader("AUTHORIZATION", token.token_type + " " + token.access_token); yield return(www.SendWebRequest()); if (www.isNetworkError || www.isHttpError) { client.Break(); Debug.Log(www.error); StatusConnection = "network connection: wait"; } else { StatusConnection = "network connection: established"; while (!www.isDone) { isDownloaded = false; yield return(new WaitForSeconds(0.5f)); } body = www.downloadHandler.text; client.GetResult(body); } } }
public static void Prefix(Player player, INetClient client) { PlayerLoginEvent cEvent = new PlayerLoginEvent(player, client); IEvent iEvent = cEvent; EventManager.CallEvent(ref iEvent); }
public bool Connect(bool bTCP, string ip, ushort port, uint newip = 0, ushort newport = 0) { if (m_TCPClient != null && m_TCPClient.IsConnected) { LogMgr.Log("TCP is connected."); return(false); } INetClient tt; //bTCP = true; bool bret; if (bTCP) { tt = new TCPClient(this); bret = tt.Connect(ip, port, newip, newport); } else { tt = new UDPClient(this); bret = tt.Connect(ip, port, newip, newport); } m_TCPClient = tt; return(bret); }
public PeerForP2PBase(object peer, object publicIP, INetClient client, bool NAT) { socket = peer; PublicIP = publicIP; this.client = client; this.NAT = NAT; }
public bool Connect(bool bTcp, string ip, ushort port, uint newip = 0, ushort newport = 0) { Debug.Log("连接到服务器 IP = " + ip); if (tCPClient != null && tCPClient.IsConnected) { Debug.Log("TCP is connected."); return(false); } INetClient tt; bool bret = true; if (bTcp) { tt = new TCPClient(this); bret = tt.Connect(ip, port); } else { tt = new UDPClient(this); bret = tt.Connect(ip, port); //tt = new UDPClient(this); //bret = tt.Connect(ip, port, newip, newport); } tCPClient = tt; return(bret); }
/// <summary> /// Initializes a new instance of the <see cref="Resource{T}" /> class. /// </summary> /// <param name="client">The client.</param> /// <param name="settings">The settings.</param> /// <param name="onError">The on error.</param> /// <param name="expression">The expression.</param> public Resource(INetClient client, ResourceSettings settings, Action <Exception> onError, Expression expression) { Client = client; Settings = settings; Provider = new RestQueryProvider <T>(this); OnError = onError; Expression = expression ?? Expression.Constant(this); }
/// <summary> /// Initializes a new instance of the <see cref="Command{T}" /> class. /// </summary> /// <param name="client">The client.</param> /// <param name="property">The property.</param> /// <param name="onError">The on error.</param> /// <param name="expression">The expression.</param> public Command(INetClient client, PropertyInfo property, Action <Exception> onError, Expression expression) { Client = client; Property = property; /////////////////////////////////////////////////////////////////Provider = new JsonRpcQueryProvider<T>(this); OnError = onError; Expression = expression ?? Expression.Constant(this); }
public void Disconnect() { if (m_TCPClient != null) { m_TCPClient.Disconnect(); m_TCPClient = null; } }
public async void ConnectToServer() { INetClient client = await this.ConnectClient(); Assert.Equal(true, client.IsConnected); client.Disconnect(); }
public void Disconnect() { if (tCPClient != null) { tCPClient.Disconnect(); tCPClient = null; } }
public static void SendShutdownServer(INetClient client) { using (var packet = new NetPacket()) { packet.Write((ushort)OpCode.Shutdown); client.Send(packet); } }
public FlightSimPlayer(INetClient netClient, IFileIterator fileIterator) { this.netClient = netClient; this.fileIterator = fileIterator; // call these functions everytime new data is read fileIterator.OnLineChanged += SendCurrentFrame; fileIterator.OnLineChanged += UpdateTimerString; fileIterator.OnLineChanged += Sleep; }
public static void AddClientEventHandler(string clientName, SocketEventHandler socketEventHandler) { INetClient client = GetClient(clientName); if (client != null) { client.OnSocketEvent += socketEventHandler; } }
/// <summary> /// Creates a new <see cref="NetClientConnector"/> instance. /// </summary> public NetClientConnector(INetClient client) { this._client = client; this._socketAsyncEvent = new SocketAsyncEventArgs { DisconnectReuseSocket = true }; this._socketAsyncEvent.Completed += this.OnCompleted; }
/// <summary> /// Creates a new <see cref="NetClientReceiver"/> instance. /// </summary> /// <param name="client">Client.</param> /// <param name="onReceiveServerDisconnect"></param> /// <param name="onReceiveSocketError"></param> public GarlicNetClientReceiver(INetClient client, EventHandler onReceiveServerDisconnect, EventHandler <SocketError> onReceiveSocketError) : base(client.PacketProcessor) { _client = client; _socketAsyncEvent = new SocketAsyncEventArgs(); _socketAsyncEvent.Completed += OnCompleted; _onReceiveServerDisconnect = onReceiveServerDisconnect; _onReceiveSocketError = onReceiveSocketError; }
public static void SendStopScriptDomain(INetClient client) { using (var packet = new NetPacket()) { packet.Write((ushort)OpCode.StopScriptDomain); client.Send(packet); Thread.Sleep(1000); } }
/// <summary> /// Sends a request to change the name of the client. /// </summary> /// <param name="client">Current client.</param> /// <param name="name">New client name.</param> public static void SetName(INetClient client, string name) { using (INetPacketStream packet = new NetPacket()) { packet.Write <byte>((byte)ChatPacketType.SetName); packet.Write <string>(name); client.Send(packet); } }
/// <summary> /// Sends a chat message. /// </summary> /// <param name="client">Current client.</param> /// <param name="message">Message to send.</param> public static void SendChatMessage(INetClient client, string message) { using (INetPacketStream packet = new NetPacket()) { packet.Write <byte>((byte)ChatPacketType.Chat); packet.Write <string>(message); client.Send(packet); } }
public static void SendWorkingDirectory(INetClient client, string workingDirectory) { using (var packet = new NetPacket()) { packet.Write((ushort)OpCode.SetWorkingDirectory); packet.Write(workingDirectory); client.Send(packet); Thread.Sleep(1000); } }
public static void DestroyClient(string name) { INetClient client = GetClient(name); if (client == null) { return; } client.Dispose(); CLIENTS.Remove(name); }
public Client(IPEndPoint serverAddress, IController controller, INetClient client) { _controller = controller; _client = client; _client.Start(); _client.Connect(serverAddress); Scene = new Scene(); Scene.Gravity = new Vector2(); }
public async void SendPacketToServer() { INetClient client = await this.ConnectClient(); if (!client.IsConnected) { throw new EtherDisconnectedException(); } // TODO Send packet and wait for answer client.Disconnect(); }
public ClientApi( IClientManager clientManager, IClientCommandManager commandManager, IUiManager uiManager, INetClient netClient, IEventAggregator eventAggregator ) { ClientManager = clientManager; CommandManager = commandManager; UiManager = uiManager; NetClient = netClient; EventAggregator = eventAggregator; }
public static void SendAuthentication(INetClient client, WorldConfiguration worldConfiguration) { using (var packet = new NetPacket()) { packet.Write((uint)ISCPacketType.AUTHENT); packet.Write(worldConfiguration.Id); packet.Write(worldConfiguration.Host); packet.Write(worldConfiguration.Name); packet.Write((byte)ISCServerType.World); packet.Write(worldConfiguration.ClusterId); // TODO: add more information to packet if needed. client.Send(packet); } }
public ClientLinker(ClientListen listen, ProtocolType protocolType, bool enableP2P) { listener = listen; type = protocolType; switch (type) { case ProtocolType.Tcp: { client = new NetClientTCP(enableP2P); break; } case ProtocolType.Udp: { client = new NetClientUDP(enableP2P); break; } } }
// Initialize Objects and add notify events private FlightModel() { netClient = new FlightNetClient(); fileIterator = new FlightDataIterator(); dataParser = new XMLParser(); dataAnalyzer = new DataAnalyzer(); libLoader = new LibraryLoader(); anomalyAnalyzer = new AnomalyAnalyzer(libLoader); selectedPlot = new MonitorGraph(dataAnalyzer, fileIterator); correlatedPlot = new MonitorGraph(dataAnalyzer, fileIterator); anomalyPlot = new AnomalyGraph(dataAnalyzer, fileIterator, anomalyAnalyzer); simPlayer = new FlightSimPlayer(netClient, fileIterator); joystick = new FlightJoystick(fileIterator, dataAnalyzer); dashboard = new FlightDashboard(fileIterator, dataAnalyzer); // add notify events simPlayer.PropertyChanged += PropertyChangedFunction; joystick.PropertyChanged += PropertyChangedFunction; dashboard.PropertyChanged += PropertyChangedFunction; }
private Event.Event createEventFromNetworkRPCEvent(INetClient client, NetworkEvent netEvent, BSONObject bson) { BSONValue value; bson.TryGetValue("method", out value); string methodname = value.StringValue; switch (methodname) { case "KeepAlive": return(FireEventTool.call(new KeepAliveEvent(client, netEvent, bson, methodname))); case "PlayerInteract": return(FireEventTool.call(new PlayerInteract(client, netEvent, bson, methodname))); default: return(FireEventTool.call(new NotregistredRPCMethodEvent(client, netEvent, bson, methodname))); } return(null); }
public void SetUp() { stubNetClient = MockRepository.GenerateStub<INetClient>(); clientNetworkSession = new LidgrenClientNetworkSession(stubNetClient, DummyLogger.Factory); }