private void Start() { receiver = GetComponent <NetworkReceiver>(); remoteEP = new IPEndPoint(IPAddress.Parse(ip), 9956); tcpClient.ReceiveTimeout = 50000; udpClient.Client.ReceiveTimeout = 50000; udpClient = new UdpClient(); }
public void Setup(string ipaddr, int port) { _socket.Connect(IPAddress.Parse(ipaddr), port); _sender = new NetworkSender(_socket); _receiver = new NetworkReceiver(_socket, ProcessRecvBuffer); _svrSeq = 0; _base = 0; _nextSendSeq = 0; _ringSendMsgAckBuffer = new Message[ACK_BUFFER_SIZE]; }
public void InitiliazeClient(NetworkReceiver networkReceiver) { Client_Socket.ReceiveBufferSize = BUFFERSIZE; //4096 Client_Socket.SendBufferSize = BUFFERSIZE; //4096 Client_Stream = Client_Socket.GetStream(); m_NetworkReceiver = networkReceiver; Array.Resize(ref m_Buffer, Client_Socket.ReceiveBufferSize); Client_Stream.BeginRead(m_Buffer, 0, Client_Socket.ReceiveBufferSize, OnReceiveData, null); }
/// <summary> /// Initliaze the game server - By button /// </summary> public void InitiliazeServer() { m_UnityServer = UnityServer.Instance; m_ServerListener = new TcpListener(IPAddress.Parse(BaseInformationReader.IpAdress), BaseInformationReader.Server_Port); m_ServerListener.Start(); m_ServerListener.BeginAcceptTcpClient(OnAcceptNewClient, null); m_NetworkReceiver = new NetworkReceiver(this); NetworkSend = new NetworkSender(this); MySQL = new MySql(); MySQL.MySQLInit(); m_UnityServer.AppendNewLog("The server has been initiliazed succesfully" + BaseInformationReader.Server_Port); InitiliazeClients(); }
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected: //ORIGINAL LINE: public ClusterClientModule(org.neo4j.kernel.lifecycle.LifeSupport life, org.neo4j.kernel.impl.util.Dependencies dependencies, final org.neo4j.kernel.monitoring.Monitors monitors, final org.neo4j.kernel.configuration.Config config, org.neo4j.logging.internal.LogService logService, org.neo4j.cluster.protocol.election.ElectionCredentialsProvider electionCredentialsProvider) public ClusterClientModule(LifeSupport life, Dependencies dependencies, Monitors monitors, Config config, LogService logService, ElectionCredentialsProvider electionCredentialsProvider) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.logging.LogProvider logging = org.neo4j.cluster.logging.AsyncLogging.provider(life, logService.getInternalLogProvider()); LogProvider logging = AsyncLogging.provider(life, logService.InternalLogProvider); InternalLoggerFactory.DefaultFactory = new NettyLoggerFactory(logging); TimeoutStrategy timeoutStrategy = (new MessageTimeoutStrategy(new FixedTimeoutStrategy(config.Get(ClusterSettings.default_timeout).toMillis()))).timeout(HeartbeatMessage.sendHeartbeat, config.Get(ClusterSettings.heartbeat_interval).toMillis()).timeout(HeartbeatMessage.timed_out, config.Get(ClusterSettings.heartbeat_timeout).toMillis()).timeout(AtomicBroadcastMessage.broadcastTimeout, config.Get(ClusterSettings.broadcast_timeout).toMillis()).timeout(LearnerMessage.learnTimedout, config.Get(ClusterSettings.learn_timeout).toMillis()).timeout(ProposerMessage.phase1Timeout, config.Get(ClusterSettings.phase1_timeout).toMillis()).timeout(ProposerMessage.phase2Timeout, config.Get(ClusterSettings.phase2_timeout).toMillis()).timeout(ClusterMessage.joiningTimeout, config.Get(ClusterSettings.join_timeout).toMillis()).timeout(ClusterMessage.configurationTimeout, config.Get(ClusterSettings.configuration_timeout).toMillis()).timeout(ClusterMessage.leaveTimedout, config.Get(ClusterSettings.leave_timeout).toMillis()).timeout(ElectionMessage.electionTimeout, config.Get(ClusterSettings.election_timeout).toMillis()); MultiPaxosServerFactory protocolServerFactory = new MultiPaxosServerFactory(new ClusterConfiguration(config.Get(ClusterSettings.cluster_name), logging), logging, monitors.NewMonitor(typeof(StateMachines.Monitor))); NetworkReceiver receiver = dependencies.satisfyDependency(new NetworkReceiver(monitors.NewMonitor(typeof(NetworkReceiver.Monitor)), new ConfigurationAnonymousInnerClass(this, config) , logging)); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.cluster.protocol.atomicbroadcast.ObjectInputStreamFactory objectInputStreamFactory = new org.neo4j.cluster.protocol.atomicbroadcast.ObjectStreamFactory(); ObjectInputStreamFactory objectInputStreamFactory = new ObjectStreamFactory(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.cluster.protocol.atomicbroadcast.ObjectOutputStreamFactory objectOutputStreamFactory = new org.neo4j.cluster.protocol.atomicbroadcast.ObjectStreamFactory(); ObjectOutputStreamFactory objectOutputStreamFactory = new ObjectStreamFactory(); receiver.AddNetworkChannelsListener(new NetworkChannelsListenerAnonymousInnerClass(this, logging, objectInputStreamFactory, objectOutputStreamFactory)); NetworkSender sender = dependencies.satisfyDependency(new NetworkSender(monitors.NewMonitor(typeof(NetworkSender.Monitor)), new ConfigurationAnonymousInnerClass(this, config) , receiver, logging)); ExecutorLifecycleAdapter stateMachineExecutor = new ExecutorLifecycleAdapter(() => Executors.newSingleThreadExecutor(new NamedThreadFactory("State machine", monitors.NewMonitor(typeof(NamedThreadFactory.Monitor))))); AcceptorInstanceStore acceptorInstanceStore = new InMemoryAcceptorInstanceStore(); _server = protocolServerFactory.NewProtocolServer(config.Get(ClusterSettings.server_id), timeoutStrategy, receiver, sender, acceptorInstanceStore, electionCredentialsProvider, stateMachineExecutor, objectInputStreamFactory, objectOutputStreamFactory, config); life.Add(sender); life.Add(stateMachineExecutor); life.Add(receiver); // Timeout timer - triggers every 10 ms life.Add(new TimeoutTrigger(_server, monitors)); life.add(new ClusterJoin(new ConfigurationAnonymousInnerClass(this, config) , _server, logService)); ClusterClient = dependencies.SatisfyDependency(new ClusterClient(life, _server)); }
public void ConnectToServer() { try { // Loggin to server _tcpClient = new TcpClient(hostName, portNum); _networkStream = _tcpClient.GetStream(); User newUser = new User(_tcpClient, _networkStream); // Creating network receiver _networkReceiver = new NetworkReceiver(newUser); _networkReceiverThread = new Thread(new ThreadStart(_networkReceiver.Process)); _networkReceiverThread.Start(); } catch (Exception e) { Console.WriteLine(e.ToString()); } }
static async Task MainAsync(string[] args) { manager = new Management.AutomationManager(); var parameters = new NetworkParameters(); parameters.ConnectionString = "HostName=AutomationSystemHub.azure-devices.net;SharedAccessKeyName=iothubowner;SharedAccessKey=oQnus5yhy5ybc10s8XidG1HOL+SQIRLTzNV7sY2Ba3Q="; parameters.ConsumerGroupName = "$Default"; parameters.DeviceName = "test"; parameters.StartTime = DateTime.Now;//Parse("2016-03-20 1:30:42Z"); var receiver = new NetworkReceiver(); receiver.MessageFeed = Digest; await receiver.Setup(parameters); sender = new NetworkSender(); sender.Setup(parameters); await receiver.Receive(); }
protected override void OnCreate(Bundle bundle) { //System.Diagnostics.Debugger.Break(); switch (Ao3TrackReader.App.Theme) { case "light": SetTheme(Ao3TrackReader.Droid.Resource.Style.LightTheme); break; case "dark": SetTheme(Ao3TrackReader.Droid.Resource.Style.DarkTheme); break; } base.OnCreate(bundle); global::Xamarin.Forms.Forms.Init(this, bundle); AndroidEnvironment.UnhandledExceptionRaiser += AndroidEnvironment_UnhandledExceptionRaiser; Java.Lang.Thread.DefaultUncaughtExceptionHandler = this; AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; //System.Threading.Tasks.TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException; Instance = this; var cm = (ConnectivityManager)GetSystemService(ConnectivityService); var netInfo = cm.ActiveNetworkInfo; var app = new App(null, netInfo?.IsConnectedOrConnecting == true); IntentFilter filter = new IntentFilter(ConnectivityManager.ConnectivityAction); receiver = new NetworkReceiver(); RegisterReceiver(receiver, filter); LoadApplication(app); app.MainPage.SizeChanged += MainPage_SizeChanged; var x = typeof(Xamarin.Forms.Themes.DarkThemeResources); x = typeof(Xamarin.Forms.Themes.LightThemeResources); x = typeof(Xamarin.Forms.Themes.Android.UnderlineEffect); }
private void btn_Ok_Click(object sender, EventArgs e) { var monitor = Owner as WaveMonitor; var Serializers = cb_Protocol.SelectedValue as IWavesSerializer; IHeritableWavesReceiver CurrentReceiver = null; switch (radioGroup1.SelectedIndex) { case 0: CurrentReceiver = new VDPMReceiver(ModuleIp); break; case 1: CurrentReceiver = new FileReceiver(FilePath, Serializers); break; case 2: CurrentReceiver = new NetworkReceiver(ServerIp, Port, Serializers); break; case 3: CurrentReceiver = new SimulateReceiver(); break; } if (CurrentReceiver != null) { CurrentReceiver.WavesReceived += monitor.waveReceiver_WavesReceived; monitor.ReceiverList.Add(CurrentReceiver); Close(); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void senderThatStartsAfterReceiverShouldEventuallyConnectSuccessfully() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void SenderThatStartsAfterReceiverShouldEventuallyConnectSuccessfully() { /* * This test verifies that a closed channel from a sender to a receiver is removed from the connections * mapping in the sender. It starts a sender, connects it to a receiver and sends a message. * * We should be testing this without resorting to using a NetworkReceiver. But, as prophets Mick Jagger and * Keith Richards mention in their scriptures, you can't always get what you want. In this case, * NetworkSender creates on its own the things required to communicate with the outside world, and this * means it creates actual sockets. To interact with it then, we need to setup listeners for those sockets * and respond properly. Hence, NetworkReceiver. Yes, this means that this test requires to open actual * network sockets. * * Read on for further hacks in place. */ NetworkSender sender = null; NetworkReceiver receiver = null; try { LogProvider logProviderMock = mock(typeof(LogProvider)); Log logMock = mock(typeof(Log)); when(logProviderMock.getLog(ArgumentMatchers.any <Type>())).thenReturn(logMock); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.concurrent.Semaphore sem = new java.util.concurrent.Semaphore(0); Semaphore sem = new Semaphore(0); /* * A semaphore AND a boolean? Weird, you may think, as the purpose is clearly to step through the * connection setup/teardown process. So, let's discuss what happens here more clearly. * * The sender and receiver are started. Trapped by the semaphore release on listeningAt() * The sender sends through the first message, it is received by the receiver. Trapped by the semaphore * release on listeningAt() which is triggered on the first message receive on the receiver * The receiver is stopped, trapped by the overridden stop() method of the logging service. * The sender sends a message through, which will trigger the ChannelClosedException. This is where it * gets tricky. See, normally, since we waited for the semaphore on NetworkReceiver.stop() and an * happensBefore edge exists and all these good things, it should be certain that the Receiver is * actually stopped and the message would fail to be sent. That would be too easy though. In reality, * netty will not wait for all listening threads to stop before returning, so the receiver is not * guaranteed to not be listening for incoming connections when stop() returns. This happens rarely, * but the result is that the message "HelloWorld2" should fail with an exception (triggering the warn * method on the logger) but it doesn't. So we can't block, but we must retry until we know the * message failed to be sent and the exception happened, which is what this test is all about. We do * that with a boolean that is tested upon continuously with sent messages until the error happens. * Then we proceed with... * The receiver is started. Trapped by the listeningAt() callback. * The sender sends a message. * The receiver receives it, trapped by the dummy processor added to the receiver. */ //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.concurrent.atomic.AtomicBoolean senderChannelClosed = new java.util.concurrent.atomic.AtomicBoolean(false); AtomicBoolean senderChannelClosed = new AtomicBoolean(false); doAnswer(invocation => { senderChannelClosed.set(true); return(null); }).when(logMock).warn(anyString()); int port = PortAuthority.allocatePort(); receiver = new NetworkReceiver(mock(typeof(NetworkReceiver.Monitor)), new ConfigurationAnonymousInnerClass(this, port) , NullLogProvider.Instance) {
Dictionary <ushort, Action <NetworkMessageInfo, NetworkMessage> > Handlers; // Dictionnaire liant un type de message à un ensemble de fonctions "Handler" à exécuter // En leur faisant passer le Message. /** * <summary> Exécutée lorsque cette instance devient le singleton de cette classe. </summary> **/ void Init() { Debugger.Log("Initialisation du MessageReader..."); Handlers = new Dictionary <ushort, Action <NetworkMessageInfo, NetworkMessage> >(); Receiver = new NetworkReceiver(); }
void Start() { receiver = GetComponent <NetworkReceiver>(); StartCoroutine("SendColor"); }