public bool TestDisconnectJetbus(Behavior behaviour) { testConnection = new TestJetbusConnection(behaviour, ipaddress, "Administrator", "wtx", delegate { return(true); }); DSEJet DSEJetObj = new DSEJet(testConnection, 500, Update); //this.connectCallbackCalled = false; DSEJetObj.Connect(this.OnConnect, 100); DSEJetObj.Disconnect(this.OnDisconnect); bool con1 = DSEJetObj.IsConnected; DSEJetObj.Connect(this.OnConnect, 100); DSEJetObj.Disconnect(); bool con2 = DSEJetObj.IsConnected; if (con1 == false && con2 == false) { return(false); } else { return(true); } }
public AirbnbSpider(ILogger <AirbnbSpider> logger, INetConnection connection, IOptions <ConfigOptions> config, IParallelManager parallelManager, SpiderParams spiderParams) : base(logger, connection, config, parallelManager) { // Connection = new NetConnectionAirbnb("https://www.airbnb.pt/rooms/5073240", logger, config); Urls = new List <string> { string.Format("https://www.airbnb.pt/rooms/ajax_refresh_subtotal?utf8=%E2%9C%93&checkin={1}&checkout={2}&number_of_guests={3}&hosting_id={0}&from_search_checkin={1}&from_search_checkout={2}", "https://www.airbnb.pt/rooms/5073240".Replace("https://www.airbnb.pt/rooms/", string.Empty), spiderParams.CheckIn, spiderParams.CheckOut, spiderParams.Adults, spiderParams.Currency) }; }
public static void ShareConnection(INetConnection connectionToShare, INetConnection homeConnection) { if ((connectionToShare == homeConnection) && (connectionToShare != null)) { throw new ArgumentException("Connections must be different"); } CleanupWMISharingEntries(); var share = GetCurrentlySharedConnections(); if (share.SharedConnection != null) { GetConfiguration(share.SharedConnection).DisableSharing(); } if (share.HomeConnection != null) { GetConfiguration(share.HomeConnection).DisableSharing(); } if (connectionToShare != null) { var sc = GetConfiguration(connectionToShare); sc.EnableSharing(tagSHARINGCONNECTIONTYPE.ICSSHARINGTYPE_PUBLIC); } if (homeConnection != null) { var hc = GetConfiguration(homeConnection); hc.EnableSharing(tagSHARINGCONNECTIONTYPE.ICSSHARINGTYPE_PRIVATE); } }
public bool CalibrationTest(Behavior behavior) { _jetTestConnection = new TestJetbusConnection(behavior, ipaddress, "Administrator", "wtx", delegate { return(true); }); _dseObj = new DSEJet(_jetTestConnection, 200, Update); _dseObj.Connect(this.OnConnect, 100); _dseObj.AdjustNominalSignal(); _dseObj.AdjustNominalSignalWithCalibrationWeight(1.5); if ( _jetTestConnection.ReadIntegerFromBuffer(JetBusCommands.CIA461CalibrationWeight) == 15000 && // LFT_SCALE_CALIBRATION_WEIGHT = "6152/00" _jetTestConnection.ReadIntegerFromBuffer(JetBusCommands.CIA461ScaleCommand) == 1852596579 // CALIBRATE_NOMINAL_WEIGHT = 1852596579 // SCALE_COMMAND = "6002/01" ) { return(true); } else { return(false); } }
/// <summary> /// Initializes a new instance of the <see cref="DSEJet" /> class. /// </summary> /// <param name="connection">Inject connection (e.g. JetBusConnection)</param> /// <param name="timerIntervalms">Interval for updating ProcessData</param> /// <param name="onProcessData">This event is automatically called when new ProcessData is available</param> public DSEJet(INetConnection connection, int timerIntervalms, EventHandler<ProcessDataReceivedEventArgs> onProcessData) : base(connection, timerIntervalms) { _connection = connection; ProcessData = new JetProcessData(Connection); ProcessDataReceived += onProcessData; }
public CurrencyfreaksSpider(ILogger <Spider <IList <Company> > > logger, INetConnection connection, IOptions <ConfigOptions> config, IParallelManager parallelManager) : base(logger, connection, config, parallelManager) { Urls = new List <string> { string.Format("https://api.currencyfreaks.com/latest?apikey={0}", "c0df19e7abca48ddaa6863b2969a85c7") }; }
public static void ShareConnection(INetConnection connectionToShare, INetConnection homeConnection) { if ((connectionToShare == homeConnection) && (connectionToShare != null)) { throw new ArgumentException("Connections must be different"); } var share = GetCurrentlySharedConnections(); if (share.SharedConnection != null) { Console.WriteLine("Disable currently shared connection"); GetConfiguration(share.SharedConnection).DisableSharing(); } if (share.HomeConnection != null) { GetConfiguration(share.HomeConnection).DisableSharing(); } if (connectionToShare != null) { var sc = GetConfiguration(connectionToShare); sc.EnableSharing(tagSHARINGCONNECTIONTYPE.ICSSHARINGTYPE_PUBLIC); } if (homeConnection != null) { var hc = GetConfiguration(homeConnection); bool fw_enabled = hc.InternetFirewallEnabled; bool ics_enabled = hc.SharingEnabled; Console.WriteLine("fw_enabled=" + fw_enabled + " ics_enabld=" + ics_enabled); if (fw_enabled == false) { hc.EnableInternetFirewall(); } hc.EnableSharing(tagSHARINGCONNECTIONTYPE.ICSSHARINGTYPE_PRIVATE); } }
public BookingPriceSpider(ILogger <BookingPriceSpider> logger, INetConnection connection, IOptions <ConfigOptions> config, IParallelManager parallelManager, SpiderParams spiderParams) : base(logger, connection, config, parallelManager) { // Connection = new NetConnectionBooking(logger, config); Urls = new List <string> { string.Format("{0}?checkin={1};checkout={2};dist=0;group_adults={3};group_children={4};selected_currency={5}", "http://www.booking.com/hotel/pt/foreign-friend-lisbon.pt-pt.html", spiderParams.CheckIn, spiderParams.CheckOut, spiderParams.Adults, spiderParams.Children, spiderParams.Currency) }; }
/// <summary> /// Constructor of class DataStandardJet : Initalizes values and connects /// the eventhandler from Connection to the interal update method /// </summary> public DataStandardJet(INetConnection Connection) { _connection = Connection; _connection.UpdateData += UpdateStandardData; WeightMemory = new WeightMemory(); Input1 = false; Input2 = false; Input3 = false; Input4 = false; _output1 = false; _output2 = false; _output3 = false; _output4 = false; LimitStatus1 = false; LimitStatus2 = false; LimitStatus3 = false; LimitStatus4 = false; _limitSwitch1Source = 0; _limitSwitch1Mode = 0; _limitSwitch1LevelAndLowerBandValue = 0; _limitSwitch1HysteresisAndBandHeight = 0; _limitSwitch2Source = 0; _limitSwitch2Mode = 0; _limitSwitch2LevelAndLowerBandValue = 0; _limitSwitch2HysteresisAndBandHeight = 0; _limitSwitch3Source = 0; _limitSwitch3Mode = 0; _limitSwitch3LevelAndLowerBandValue = 0; _limitSwitch3HysteresisAndBandHeight = 0; _limitSwitch4Source = 0; _limitSwitch4Mode = 0; _limitSwitch4LevelAndLowerBandValue = 0; _limitSwitch4HysteresisAndBandHeight = 0; }
public static NetShare GetCurrentlySharedConnections() { INetConnection sharedConnection = null; INetConnection homeConnection = null; INetSharingEveryConnectionCollection connections = SharingManager.EnumEveryConnection; foreach (INetConnection c in connections) { try { INetSharingConfiguration config = GetConfiguration(c); if (config.SharingEnabled) { if (config.SharingConnectionType == tagSHARINGCONNECTIONTYPE.ICSSHARINGTYPE_PUBLIC) { sharedConnection = c; Console.WriteLine("SharedConnection=" + c.ToString()); } else if (config.SharingConnectionType == tagSHARINGCONNECTIONTYPE.ICSSHARINGTYPE_PRIVATE) { homeConnection = c; Console.WriteLine("homeConnection=" + c.ToString()); } } } catch (System.Runtime.InteropServices.ExternalException) { } } return(new NetShare(sharedConnection, homeConnection)); }
/// <summary> /// Constructor of class DataStandardModbus : Initalizes values and connects /// the eventhandler from Connection to the interal update method /// </summary> /// <param name="Connection">Target connection</param> public ModbusDataLimitSwitch(INetConnection Connection) { _connection = Connection; _connection.UpdateData += UpdateDataLimitSwitch; LimitStatus1 = false; LimitStatus2 = false; LimitStatus3 = false; LimitStatus4 = false; _limitSwitch1Source = LimitSwitchSource.Gross; _limitSwitch1Mode = LimitSwitchMode.AboveLevel; _limitSwitch1LevelAndLowerBandValue = 0; _limitSwitch1HysteresisAndBandHeight = 0; _limitSwitch2Source = LimitSwitchSource.Gross; _limitSwitch2Mode = LimitSwitchMode.AboveLevel; _limitSwitch2LevelAndLowerBandValue = 0; _limitSwitch2HysteresisAndBandHeight = 0; _limitSwitch3Source = LimitSwitchSource.Gross; _limitSwitch3Mode = LimitSwitchMode.AboveLevel; _limitSwitch3LevelAndLowerBandValue = 0; _limitSwitch3HysteresisAndBandHeight = 0; _limitSwitch4Source = LimitSwitchSource.Gross; _limitSwitch4Mode = LimitSwitchMode.AboveLevel; _limitSwitch4LevelAndLowerBandValue = 0; _limitSwitch4HysteresisAndBandHeight = 0; }
/// <summary> /// For a more simple solution : Constructor with no asynchronous callback and no timer interval for continously updating the data. /// </summary> /// <param name="connection"></param> public WTXModbus(INetConnection connection) : base(connection) { ProcessData = new ModbusDataProcess(base.Connection); Filler = new ModbusDataFiller(base.Connection); DigitalIO = new ModbusDataDigitalIO(base.Connection); LimitSwitch = new ModbusDataLimitSwitch(base.Connection); }
public bool ReadMessage(NetBuffer intoBuffer, out NetMessageType type, out INetConnection sender) { NetConnection senderInternal; bool messageExists = _netServer.ReadMessage(intoBuffer, out type, out senderInternal); sender = new NetConnectionWrapper(senderInternal); return messageExists; }
/// <summary> /// Initializes a new instance of the <see cref="BaseWTDevice" /> class. /// </summary> /// <param name="connection">Target connection of the device</param> /// <param name="timerIntervalms">Interval for updating ProcessData</param> public BaseWTDevice(INetConnection connection, int timerIntervalms) { Connection = connection; _processDataInterval = timerIntervalms; _processDataTimer = new Timer(ProcessDataUpdateTick, null, Timeout.Infinite, Timeout.Infinite); }
public bool Start() { try { INetConnection dialer = GetDialerConnection(); INetConnection wifi = GetAPConnection(); if (dialer == null || wifi == null) { return(false); } INetSharingConfiguration wconf = nsm.INetSharingConfigurationForINetConnection[wifi]; Disable_ICS_WMI(false); if (wconf.SharingEnabled) { wconf.DisableSharing(); } wconf.EnableSharing(tagSHARINGCONNECTIONTYPE.ICSSHARINGTYPE_PRIVATE); INetSharingConfiguration dconf = nsm.INetSharingConfigurationForINetConnection[dialer]; Disable_ICS_WMI(true); if (dconf.SharingEnabled) { dconf.DisableSharing(); } // System.AccessViolationException??? dconf.EnableSharing(tagSHARINGCONNECTIONTYPE.ICSSHARINGTYPE_PUBLIC); } catch (Exception e) { Log4Net.WriteLog("Enable sharing wifi failed", e); return(false); } return(true); }
/// <summary> /// Receive data from a client. /// </summary> /// <param name="client">Client.</param> /// <param name="socketAsyncEvent">Socket async event arguments.</param> private void ReceiveData(INetConnection client, SocketAsyncEventArgs socketAsyncEvent) { if (!client.Socket.ReceiveAsync(socketAsyncEvent)) { ProcessReceive(socketAsyncEvent.UserToken as NetToken, socketAsyncEvent); } }
/// <summary> /// Constructor of class DataFillerJet : Initalizes values and connects /// the eventhandler from Connection to the interal update method /// </summary> public DataFillerJet(INetConnection Connection) { _connection = Connection; _connection.UpdateData += UpdateFillerData; _residualFlowTime = 0; _targetFillingWeight = 0; _coarseFlowCutOffPointSet = 0; _fineFlowCutOffPointSet = 0; _minimumFineFlow = 0; _optimizationOfCutOffPoints = 0; _maximumDosingTime = 0; _startWithFineFlow = 0; _coarseLockoutTime = 0; _fineLockoutTime = 0; _tareMode = 0; _upperToleranceLimit = 0; _lowerToleranceLimit = 0; _minimumStartWeight = 0; _emptyWeight = 0; _tareDelay = 0; _coarseFlowMonitoringTime = 0; _coarseFlowMonitoring = 0; _fineFlowMonitoring = 0; _fineFlowMonitoringTime = 0; _delayTimeAfterFineFlow = 0; _activationTimeAfterFineFlow = 0; _systematicDifference = 0; _downwardsDosing = 0; _valveControl = 0; _emptyingMode = 0; }
public DumbstockapiSpider(ILogger <Spider <IList <Company> > > logger, INetConnection connection, IOptions <ConfigOptions> config, IParallelManager parallelManager) : base(logger, connection, config, parallelManager) { Urls = new List <string> { string.Format("https://dumbstockapi.com/stock?countries={0}", "US") }; }
public void SendTo(Message msg, global::Lidgren.Network.NetChannel channel, INetConnection destinationConnection) { var buffer = _netServer.CreateBuffer(); buffer.Write(msg); _netServer.SendMessage(buffer, channel, destinationConnection); }
public void SendToAllExcept(Message msg, global::Lidgren.Network.NetChannel channel, INetConnection excludedConnection) { var buffer = _netServer.CreateBuffer(); buffer.Write(msg); _netServer.SendToAll(buffer, channel, excludedConnection); }
private static void DisableSharing(INetConnection hotspotName, INetConnection interfaceForShareName) { if (hotspotName != null) GetConfiguration_HotSpotConn(hotspotName).DisableSharing(); if (interfaceForShareName != null) GetConfiguration_HotSpotConn(interfaceForShareName).DisableSharing(); }
public LinkedinSpider(ILogger <LinkedinSpider> logger, INetConnection connection, IOptions <ConfigOptions> config, IParallelManager parallelManager) : base(logger, connection, config, parallelManager) { _searchWord = "hotel teatro porto"; // Connection = new NetConnectionLinkedin(logger, config); Urls = new List <string> { string.Format("https://www.linkedin.com/vsearch/p?type=people&keywords={0}", _searchWord) }; }
public RemoteClient(INetConnection netConnection) { ClientConnection = netConnection; ClientProtocol = new Protocol.UnknownProtocol(this); StreamReader = new ByteReader(netConnection); StreamWriter = new ByteWriter(netConnection); State = ClientState.Handshaking; }
public Task Handle(INetConnection connection, AskCommandRequest command) { connection.SendMessage(PacketId.ACK_COMMAND_RESPONSE, new AskCommandResponse() { Command = Command.ASK_DATETIME }); return(Task.CompletedTask); }
/// <summary> /// Initializes a new instance of the <see cref="WTXJet" /> class. /// </summary> /// <param name="connection">Inject connection (e.g. JetBusConnection)</param> /// <param name="onProcessData">This event is automatically called when new ProcessData is available</param> public WTXModbus(INetConnection connection, int timerIntervalms, EventHandler <ProcessDataReceivedEventArgs> onProcessData) : base(connection, timerIntervalms) { ProcessData = new ProcessDataModbus(base.Connection); DataStandard = new DataStandardModbus(base.Connection); DataFiller = new DataFillerModbus(base.Connection); ProcessDataReceived += onProcessData; }
public FinvizSpider(ILogger <Spider <Company> > logger, INetConnection connection, IOptions <ConfigOptions> config, IParallelManager parallelManager, Company spiderParams) : base(logger, connection, config, parallelManager) { Company = spiderParams; Urls = new List <string> { string.Format("https://finviz.com/quote.ashx?t={0}", spiderParams.Symbol) }; }
public PriceGoogleSpider(ILogger <Spider <Company> > logger, INetConnection connection, IOptions <ConfigOptions> config, IParallelManager parallelManager, Company spiderParams) : base(logger, connection, config, parallelManager) { Company = spiderParams; Urls = new List <string> { string.Format("http://performance.morningstar.com/perform/Performance/stock/quote-data-strip.action?t={0}®ion=usa&culture=en-US", spiderParams.Symbol) }; }
/// <summary> /// Initializes a new instance of the <see cref="WTXJet" /> class. /// </summary> /// <param name="connection">Inject connection (e.g. JetBusConnection)</param> /// <param name="onProcessData">This event is automatically called when new ProcessData is available</param> public WTXModbus(INetConnection connection, int timerIntervalms, EventHandler <ProcessDataReceivedEventArgs> onProcessData) : base(connection, timerIntervalms) { ProcessData = new ModbusDataProcess(base.Connection); LimitSwitch = new ModbusDataLimitSwitch(base.Connection); DigitalIO = new ModbusDataDigitalIO(base.Connection); ProcessDataReceived += onProcessData; }
/// <summary> /// Constructor of class DataFillerModbus : Initalizes values and connects /// the eventhandler from Connection to the interal update method /// </summary> public DataFillerModbus(INetConnection Connection) : base() { _connection = Connection; _connection.UpdateData += UpdateFillerData; CoarseFlow = 0; FineFlow = 0; Ready = 0; ReDosing = 0; Emptying = 0; FlowError = 0; Alarm = 0; AdcOverUnderload = 0; FillingProcessStatus = 0; FillingResultCount = 0; FillingResult = 0; FillingResultMeanValue = 0; FillingResultStandardDeviation = 0; FillingResultTotalSum = 0; CurrentDosingTime = 0; CurrentCoarseFlowTime = 0; CurrentFineFlowTime = 0; ToleranceErrorPlus = 0; ToleranceErrorMinus = 0; StatusInput1 = 0; GeneralScaleError = 0; FineFlowCutOffPoint = 0; CoarseFlowCutOffPoint = 0; ParameterSetProduct = 0; MaxDosingTime = 0; _residualFlowTime = 0; _targetFillingWeight = 0; _coarseFlowCutOffPointSet = 0; _fineFlowCutOffPointSet = 0; _minimumFineFlow = 0; _optimizationOfCutOffPoints = 0; _maximumDosingTime = 0; _startWithFineFlow = 0; _coarseLockoutTime = 0; _fineLockoutTime = 0; _tareMode = 0; _upperToleranceLimit = 0; _lowerToleranceLimit = 0; _minimumStartWeight = 0; _emptyWeight = 0; _tareDelay = 0; _coarseFlowMonitoringTime = 0; _coarseFlowMonitoring = 0; _fineFlowMonitoring = 0; _fineFlowMonitoringTime = 0; _delayTimeAfterFineFlow = 0; _activationTimeAfterFineFlow = 0; _systematicDifference = 0; _downwardsDosing = 0; _valveControl = 0; _emptyingMode = 0; }
/// <summary> /// Initializes a new instance of the <see cref="WTXJet" /> class. /// </summary> /// <param name="connection">Inject connection (e.g. JetBusConnection)</param> /// <param name="timerIntervalms">Interval for updating ProcessData</param> /// <param name="onProcessData">This event is automatically called when new ProcessData is available</param> public WTXJet(INetConnection connection, int timerIntervalms, EventHandler <ProcessDataReceivedEventArgs> onProcessData) : base(connection, timerIntervalms) { _connection = connection; ProcessData = new ProcessDataJet(Connection); DataStandard = new DataStandardJet(Connection); DataFiller = new DataFillerExtendedJet(Connection); ProcessDataReceived += onProcessData; }
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. protected Spider(ILogger <Spider <T> > logger, INetConnection connection, IOptions <ConfigOptions> config, IParallelManager parallelManager) #pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. { _config = config.Value; _logger = logger; Connection = connection; ParallelManager = parallelManager; FileUrlsLog = new FileJson($"{GetType().Name}{"ErrorItens.json"}", _config.LogFolder); }
//BinaryReader _br; /* * public ByteReader(byte[] array, int offset, int length) * { * if (offset == 0 && array.Length == length) * { * _array = new byte[length]; * Array.Copy(array, offset, _array, 0, length); * } * else * { * _array = array; * } * Init(); * } * * public ByteReader(byte[] array) * : this(array, 0, array.Length) * { * * } */ public ByteReader(INetConnection connection) { _connection = connection; _stream = _connection.Stream; // _br = new BinaryReader(_stream); //_array = new byte[length]; //stream.Read(_array, offset, length); Init(); }
/// <summary> /// Initializes a new instance of the <see cref="WTXJet" /> class. /// </summary> /// <param name="connection">Inject connection (e.g. JetBusConnection)</param> /// <param name="timerIntervalms">Interval for updating ProcessData</param> /// <param name="onProcessData">This event is automatically called when new ProcessData is available</param> public WTXJet(INetConnection connection, int timerIntervalms, EventHandler <ProcessDataReceivedEventArgs> onProcessData) : base(connection, timerIntervalms) { _connection = connection; ProcessData = new JetProcessData(Connection); DigitalIO = new JetDataDigitalIO(Connection); Filler = new JetDataFillerExtended(Connection); LimitSwitch = new JetDataLimitSwitch(Connection); ProcessDataReceived += onProcessData; }
/// <summary> /// Sends the message data to the given <see cref="INetConnection"/>. /// </summary> /// <param name="connection">Client connection.</param> /// <param name="data">Message data.</param> private void SendMessage(INetConnection connection, byte[] data) { SocketAsyncEventArgs socketAsyncEvent = GetSocketEvent(); socketAsyncEvent.SetBuffer(data, 0, data.Length); if (!connection.Socket.SendAsync(socketAsyncEvent)) { OnSendCompleted(this, socketAsyncEvent); } }
internal ICSConnection(INetSharingManager nsManager, INetConnection netConnection) { if (nsManager == null) { throw new ArgumentNullException("nsManager"); } if (netConnection == null) { throw new ArgumentNullException("netConnection"); } this._netConnectionProperties = nsManager.NetConnectionProps[netConnection]; this._netSharingConfiguration = nsManager.INetSharingConfigurationForINetConnection[netConnection]; }
public void SetUp() { stubNetServer = MockRepository.GenerateStub<INetServer>(); stubMessageSender = MockRepository.GenerateStub<IServerMessageSender>(); stubNetConnection = MockRepository.GenerateStub<INetConnection>(); stubDisconnectingConnection = MockRepository.GenerateStub<INetConnection>(); serverNetworkSession = new LidgrenServerNetworkSession(stubNetServer, stubMessageSender, DummyLogger.Factory); stubNetConnection.Stub(x => x.Status).Return(NetConnectionStatus.Connected); stubNetConnection.Stub(x => x.ConnectionID).Return(100); stubDisconnectingConnection.Stub(x => x.Status).Return(NetConnectionStatus.Disconnecting); stubDisconnectingConnection.Stub(x => x.ConnectionID).Return(200); serverNetworkSession.ActiveConnections.Add(200, stubDisconnectingConnection); }
public static void ShareConnection(INetConnection connectionToShare, INetConnection homeConnection) { if ((connectionToShare == homeConnection) && (connectionToShare != null)) throw new ArgumentException("Connections must be different"); var share = GetCurrentlySharedConnections(); if (share.SharedConnection != null) GetConfiguration(share.SharedConnection).DisableSharing(); if (share.HomeConnection != null) GetConfiguration(share.HomeConnection).DisableSharing(); if (connectionToShare != null) { var sc = GetConfiguration(connectionToShare); sc.EnableSharing(tagSHARINGCONNECTIONTYPE.ICSSHARINGTYPE_PUBLIC); } if (homeConnection != null) { var hc = GetConfiguration(homeConnection); hc.EnableSharing(tagSHARINGCONNECTIONTYPE.ICSSHARINGTYPE_PRIVATE); } }
/// <summary> /// Send a message to a specific connection /// </summary> /// <param name="msg">The message to send</param> /// <param name="recipient">The recipient connection</param> /// <param name="method">How to deliver the message</param> /// <param name="sequenceChannel">Sequence channel within the delivery method</param> public NetSendResult SendMessage(INetOutgoingMessage msg, INetConnection recipient, NetDeliveryMethod method, int sequenceChannel) { NetOutgoingMessage _msg = (NetOutgoingMessage)msg; NetConnection _recipient = (NetConnection)recipient; if (msg == null) throw new ArgumentNullException("msg"); if (recipient == null) throw new ArgumentNullException("recipient"); if (sequenceChannel >= NetConstants.NetChannelsPerDeliveryMethod) throw new ArgumentOutOfRangeException("sequenceChannel"); NetException.Assert( ((method != NetDeliveryMethod.Unreliable && method != NetDeliveryMethod.ReliableUnordered) || ((method == NetDeliveryMethod.Unreliable || method == NetDeliveryMethod.ReliableUnordered) && sequenceChannel == 0)), "Delivery method " + method + " cannot use sequence channels other than 0!" ); NetException.Assert(method != NetDeliveryMethod.Unknown, "Bad delivery method!"); if (_msg.m_isSent) throw new NetException("This message has already been sent! Use NetPeer.SendMessage() to send to multiple recipients efficiently"); _msg.m_isSent = true; bool suppressFragmentation = (method == NetDeliveryMethod.Unreliable || method == NetDeliveryMethod.UnreliableSequenced) && m_configuration.UnreliableSizeBehaviour != NetUnreliableSizeBehaviour.NormalFragmentation; int len = NetConstants.UnfragmentedMessageHeaderSize + msg.LengthBytes; // headers + length, faster than calling msg.GetEncodedSize if (len <= _recipient.m_currentMTU || suppressFragmentation) { Interlocked.Increment(ref _msg.m_recyclingCount); return _recipient.EnqueueMessage(_msg, method, sequenceChannel); } else { // message must be fragmented! if (_recipient.m_status != NetConnectionStatus.Connected) return NetSendResult.FailedNotConnected; return SendFragmentedMessage(_msg, new NetConnection[] { _recipient }, method, sequenceChannel); } }
/// <summary> /// Send a message to all connections except one /// </summary> /// <param name="msg">The message to send</param> /// <param name="method">How to deliver the message</param> /// <param name="except">Don't send to this particular connection</param> /// <param name="sequenceChannel">Which sequence channel to use for the message</param> public void SendToAll(NetOutgoingMessage msg, INetConnection except, NetDeliveryMethod method, int sequenceChannel) { var all = this.Connections; if (all.Count <= 0) { if (msg.m_isSent == false) Recycle(msg); return; } if (except == null) { SendMessage(msg, all, method, sequenceChannel); return; } List<INetConnection> recipients = new List<INetConnection>(all.Count - 1); foreach (var conn in all) if (conn != except) recipients.Add(conn); if (recipients.Count > 0) SendMessage(msg, recipients, method, sequenceChannel); }
public void SendToAll(NetBuffer data, NetChannel channel, INetConnection exclude) { _netServer.SendToAll(data, channel, exclude.NetConnection); }
public NetSendResult SendMessage(INetOutgoingMessage msg, INetConnection recipient, NetDeliveryMethod method, int sequenceChannel) { return NetSendResult.Sent; }
public void SendMessage(NetBuffer data, NetChannel channel, INetConnection connection) { _netServer.SendMessage(data, connection.NetConnection, channel); }
public IcsConnection(INetSharingManager pIcsMgr, INetConnection pNetConnection) { this.INetConnection = pNetConnection; this._NSManager = pIcsMgr; }
public void SetUp() { stubNetServer = MockRepository.GenerateStub<INetServer>(); stubNetConnection = MockRepository.GenerateStub<INetConnection>(); serverMessageSender = new LidgrenServerMessageSender(stubNetServer, DummyLogger.Factory); }
public static INetSharingConfiguration GetConfiguration(INetConnection connection) { return SharingManager.get_INetSharingConfigurationForINetConnection(connection); }
void ApproveNewClient(INetConnection client) { _logger.Info("Client attempted to connect, approving..."); client.Approve(); }
/// <summary> /// Send a message to a specific connection /// </summary> /// <param name="msg">The message to send</param> /// <param name="recipient">The recipient connection</param> /// <param name="method">How to deliver the message</param> public NetSendResult SendMessage(INetOutgoingMessage msg, INetConnection recipient, NetDeliveryMethod method) { return SendMessage(msg, recipient, method, 0); }
void HandleClientStatusChanged(INetConnection clientConnection) { _logger.Info("Status for " + clientConnection.ConnectionID.ToString() + " is: " + clientConnection.Status); if ((clientConnection.Status == NetConnectionStatus.Connected) && (!ActiveConnections.ContainsKey(clientConnection.ConnectionID))) { ActiveConnections.Add(clientConnection.ConnectionID, clientConnection); ProcessNewClient(clientConnection.ConnectionID); } else if ((clientConnection.Status == NetConnectionStatus.Disconnecting) && (ActiveConnections.ContainsKey(clientConnection.ConnectionID))) { ActiveConnections.Remove(clientConnection.ConnectionID); ProcessDisconnectingClient(clientConnection.ConnectionID); } }
public void SetConnection(INetConnection connection) { this.SetConnection(connection, -1, -1); }
public NetShare(INetConnection sharedConnection, INetConnection homeConnection) { SharedConnection = sharedConnection; HomeConnection = homeConnection; }
private static INetConnectionProps GetProperties(INetConnection connection) { return _SharingManager.get_NetConnectionProps(connection); }
public void SetConnection(INetConnection connection, int port, int connectionid) { this.mProcessing = false; if (this.mProcessThread != null) { this.mProcessThread.Interrupt(); this.mProcessThread.Join(); } if (this.mConnection != null) { this.mConnection.Close(); } this.mConnection = connection; if (!this.mConnection.IsBound) { this.mConnection.Bind(port, connectionid); } this.mConnection.OnReceiveMessage += new ReceiveMessage(this.mConnection_OnReceiveMessage); this.StartThread(); }
private static INetSharingConfiguration GetConfiguration_HotSpotConn(INetConnection conn) { return _SharingManager.get_INetSharingConfigurationForINetConnection(conn); }
private void EnableandShareConnection(INetConnection ToShareConnetion, INetConnection SharedConnection) { try { GetConfiguration_HotSpotConn(ToShareConnetion).EnableSharing(tagSHARINGCONNECTIONTYPE.ICSSHARINGTYPE_PRIVATE); GetConfiguration_HotSpotConn(SharedConnection).EnableSharing(tagSHARINGCONNECTIONTYPE.ICSSHARINGTYPE_PUBLIC); } catch (Exception e) { GetMessageBox(); } }