public void OpenedChannelsReceiveData() { Acceptor.Start(); for (int i = 0; i < Clients.Length; i++) { StartClientConnect(i); } byte[] testData = new byte[5000]; for (int i = 0; i < testData.Length; i++) { testData[i] = (byte)(i * i); } WaitForConnections(Clients.Length); foreach (Socket client in Clients) { client.Send(testData); } foreach (Socket socket in OpenedConnections) { byte[] rcvData = new byte[6000]; int byteCount = 0; while ((byteCount += socket.Receive(rcvData, byteCount, rcvData.Length - byteCount, SocketFlags.None)) < testData.Length) { // receive in loop } Assert.Equal(testData.Length, byteCount); Array.Resize(ref rcvData, byteCount); Assert.True(testData.SequenceEqual(rcvData)); } }
public void NewAcceptor_AcceptedProposal_IsNotNull() { var sut = new Acceptor <string>("sample-acceptor"); Assert.NotNull(sut.PromisedProposal); Assert.Equal(long.MinValue, sut.PromisedProposalNumber); }
public void OpenedChannelsSendData() { Acceptor.Start(); for (int i = 0; i < Clients.Length; i++) { StartClientConnect(i); } byte[] testData = new byte[5000]; for (int i = 0; i < testData.Length; i++) { testData[i] = (byte)(i * i); } WaitForConnections(Clients.Length); foreach (Socket connection in OpenedConnections) { connection.Send(testData); } WaitForData(testData.Length * Clients.Length); foreach (Socket client in Clients) { VerifyOtherEndData(client, testData); } }
public override IceInternal.Acceptor acceptor(ref IceInternal.EndpointI endpoint, string adapterName) { Acceptor p = new Acceptor(_endpoint.acceptor(ref endpoint, adapterName)); endpoint = new EndpointI(endpoint); return(p); }
void DeleteAcceptorUser(Acceptor Acceptor) { if (Acceptor != null) { bool deletionResult = _serviceProxy.DeleteDependentUser(Acceptor); if (deletionResult) { GetAcceptors(); } else { Messenger.Default.Send(new ErrorMessage() { Error = Resources.Strings.UserSelectionErrorTitle, Title = Resources.Strings.NoDependentUserError }); } } else { Messenger.Default.Send(new ErrorMessage() { Title = Resources.Strings.UserSelectionErrorTitle, Error = Resources.Strings.SelectUserFirstError }); } }
static void Main(string[] args) { string s = " "; Packet p = new Packet(); p.WriteString(s); try { MyReceiver receiver = new MyReceiver(); var maxConnect = 1024; AsyncIOManager netserver = new AsyncIOManager(4, receiver, 1024, maxConnect, 512); AsyncSocket prototype = AsyncSocket.GetPrototype(); AsyncSocket.InitUIDAllocator(1, maxConnect); Acceptor acceptor = new Acceptor(netserver, prototype, "192.168.0.79", 3210); acceptor.Start(); while (true) { // 이 예제는 연결된 클라이언트들에게 2초마다 뭔가를 날려줍니다요~ System.Threading.Thread.Sleep(2000); receiver.Process(); } } catch (Exception ex) { Console.WriteLine(ex.Message); Console.ReadLine(); } }
public void AddListAcceptor(string strtype, string strvalue) { Acceptor acceptor = new Acceptor(); int laccCount = listacceptor.Count; bool newBankNote = true; acceptor.Type = strtype; acceptor.Value = strvalue; acceptor.Count = 1; for (int i = 0; i < laccCount; i++) { if (acceptor.Type == listacceptor[i].Type) { if (acceptor.Value == listacceptor[i].Value) { listacceptor[i].Count += 1; newBankNote = false; break; } } } if (newBankNote) { listacceptor.Add(acceptor); } }
public RxBufNaive(Node n, Evictor ev, Acceptor a) { m_n = n; m_ev = ev; m_a = a; switch (Config.rxbuf_mode) { case RxBufMode.JIT: m_rx_jit_buf = new Flit[Config.rxbuf_size]; for (int i = 0; i < m_rx_jit_buf.Length; i++) m_rx_jit_buf[i] = null; break; case RxBufMode.PSA: m_rx_psa_buf = new Packet[Config.rxbuf_size / Config.router.maxPacketSize]; m_rx_psa_state = new PSAState[m_rx_psa_buf.Length, Config.router.maxPacketSize]; m_rx_psa_flits = new Flit[m_rx_psa_buf.Length, Config.router.maxPacketSize]; for (int i = 0; i < m_rx_psa_buf.Length; i++) { m_rx_psa_buf[i] = null; for (int j = 0; j < Config.router.maxPacketSize; j++) { m_rx_psa_state[i,j] = PSAState.EMPTY; m_rx_psa_flits[i,j] = null; } } break; case RxBufMode.NONE: break; } }
static void Server( ) { Console.WriteLine("server"); var ed = new EventDispatcher(); var codec = new ProtobufCodec(); var peer = new Acceptor(ed.Queue, codec).Start("127.0.0.1:7010"); Subscribe.RegisterMessage <gamedef.SessionAccepted>(ed, (msg, ses) => { Console.WriteLine("SessionAccepted"); }); var meter = new QPSMeter(ed, (qps) => { Console.WriteLine("qps: {0}", qps); }); Subscribe.RegisterMessage <gamedef.TestEchoACK>(ed, (msg, ses) => { meter.Acc(); ses.Send(msg); }); ed.Start(); ed.Wait(); }
static void Main(string[] args) { var userkey = new byte[] //europe maplestory key { 0x13, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0xB4, 0x00, 0x00, 0x00, 0x1B, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x00, 0x52, 0x00, 0x00, 0x00 }; var aes = new AesCipher(userkey); var info = new ServerInfo() { Version = 97, Subversion = "1", Locale = 9 }; using (var acceptor = new Acceptor(info, aes, 8484)) { acceptor.OnClientAccepted += OnClientAccepted; acceptor.Start(); Console.ReadLine(); } }
public async Task Acceptor_OlderPrepareRequest_Rejected() { var acceptor = new Acceptor <string>("sample-acceptor"); var winningProposal = new Proposal <string>(100, "192.168.0.100"); var winningRequest = new PrepareRequest(winningProposal); var winningResponse = await acceptor.ReceivePrepareRequestAsync(winningRequest) .ConfigureAwait(false); var newProposal = new Proposal <string>(99, "192.168.0.99"); var newRequest = new PrepareRequest(newProposal); var newResponse = await acceptor.ReceivePrepareRequestAsync(newRequest) .ConfigureAwait(false); Assert.NotNull(newResponse); Assert.False(newResponse.Promised); Assert.NotNull(newResponse.AcceptedProposal); Assert.IsType <Proposal <string> >(newResponse.AcceptedProposal); Assert.IsNotType <Proposal <object> >(newResponse.AcceptedProposal); Assert.IsNotType <Proposal <int> >(newResponse.AcceptedProposal); Assert.Equal(winningProposal, winningResponse.AcceptedProposal); Assert.Equal(100, acceptor.PromisedProposalNumber); Assert.NotNull(acceptor.PromisedProposal.As <Proposal <string> >()); Assert.Equal("192.168.0.100", acceptor.PromisedProposal.As <Proposal <string> >() !.Value); Assert.Equal($"sample-acceptor: Proposal {{ Number = 100, Value = 192.168.0.100 }}", acceptor.ToString()); }
/// <summary> /// Finds the acceptor by ID. /// </summary> /// <param name="Id">The identifier.</param> /// <returns>Acceptor or null if nothing matched</returns> public Acceptor FindAcceptor(int Id) { Acceptor acceptor = new Acceptor(); context.Acceptors.Load(); acceptor = context.Acceptors.Find(Id); return(acceptor); }
/// <summary> /// Set things in motion so your service can do its work. /// </summary> protected override void OnStart(string[] args) { // TODO: Add code here to start your service. ep = new IPEndPoint(0, 12001); a = new Acceptor(new DefaultServiceHandlerFactory()); a.open(ep); a.accept(); }
public BrokenEvent(Acceptor acceptor, Session session) : base() { string stackTrace = Runtime.GetStackTrace(); logReport.OnWarningReport(stackTrace); logReport.OnWarningReport("fire Broken,sessionid:" + session.Id); this.acceptor = acceptor; this.session = session; }
public AcceptRequest(Acceptor listeningPort, HazelSocket listenSocket, HazelSocket socket)//, int dataLength) : base(null) { _acceptor = listeningPort; _listenSocket = listenSocket; _socket = socket; _byteBuffer = new ByteBuffer((HazelAddress.MaxSize + 4) * 2 + 100); //dataLength); PinObject(_byteBuffer.Array); }
public ServerBase(short port) { m_acceptor = new Acceptor(port); m_acceptor.OnClientAccepted = OnClientAccepted; m_clients = new List <MapleClient>(); SpawnHandlers(); }
/// <summary> Starts waiting in a separate thread for connections to the given /// ServerSocket from the given IP address. /// </summary> /// <param name="theServer"> /// </param> /// <param name="theAddress">IP address from which to accept connections (null /// means any) /// </param> public Acceptor(System.Net.Sockets.TcpListener theServer, System.String theAddress) { Acceptor a = this; IThreadRunnable r = new AnonymousClassRunnable(a, theServer, theAddress, this); SupportClass.ThreadClass thd = new SupportClass.ThreadClass(new System.Threading.ThreadStart(r.Run)); thd.Start(); }
protected ServerBase(string label, short port) { mLabel = label; mAcceptor = new Acceptor(port); mAcceptor.OnClientAccepted = this.OnClientAccepted; mProcessor = new PacketProcessor(mLabel); mClients = new List <MapleClient>(); this.SpawnHandlers(); }
public HellEmissary(short port) { m_acceptor = new Acceptor(port); m_acceptor.OnClientAccepted = OnClientAccepted; m_clients = new List <MartialClient>(); PacketHandlers(); CommandProcessor.InitCommandHandlers(); }
public static XObject Accept(this XObject node, XObjectVisitor visitor) { CheckNullReference(node); CheckArgumentNull(visitor, "visitor"); // yay, easy dynamic dispatch Acceptor acceptor = new Acceptor(node as dynamic); return(acceptor.Accept(visitor)); }
public frmMain() { MapleKeys.Initialize(); this.InitializeComponent(); this.Acceptor = new Acceptor(8484); this.Acceptor.OnClientAccepted = OnClientAccepted; frmMain.Instance = this; }
protected Token TokenOf(Acceptor acceptor) { var found = Lexicon.FirstOrDefault(pair => pair.Item2.ValueOf == acceptor); var token = found != null ? found.Item2 : null; if ((token == null) && (acceptor != Commenting)) { throw Error("missing required token definition: {0}", acceptor.Method.Name); } return(token); }
/// <summary> /// Initializes a new instance of the <see cref="AcceptorsViewModel"/> class. /// </summary> /// <param name="serviceProxy">The data access service.</param> public AcceptorsViewModel(IAcceptorsDataService serviceProxy) { _serviceProxy = serviceProxy; Acceptors = new ObservableCollection <Acceptor>(); SelectedAcceptor = new Acceptor(); RefreshCommand = new RelayCommand(GetAcceptors); SendAcceptorCommand = new RelayCommand <Acceptor>(SendAcceptor); SaveAcceptorCommand = new RelayCommand(SaveAcceptor); DeleteAcceptorUserCommand = new RelayCommand <Acceptor>(DeleteAcceptorUser); CancelCommand = new RelayCommand(Cancel); GetAcceptors(); }
protected Token TokenOf(Acceptor acceptor) { var optional = new Acceptor[] { Commenting, Parameters, Self }; var found = Lexicon.FirstOrDefault(pair => pair.Item2.ValueOf == acceptor); var token = found != null ? found.Item2 : null; if ((token == null) && !Optional.Contains(acceptor)) { throw Language.Error("missing required token definition: {0}", acceptor.Method.Name); } return(token); }
public void Start() { acceptor = new Acceptor(); acceptor.Start(); decoder = new DefaultSocketDecoder(); encoder = new DefaultSocketEncoder(); httpDecoder = new DefaultDecoder(); httpEncoder = new DefaultEncoder(); heartBeatPackage = new Msg(BaseCodeMap.BaseCmd.CMD_HEART_BEAT); SessionConfig sessionConfig = new SessionConfig(10, 10); gameSrvClient = getClient(null, onMsgPush, sessionConfig); }
static void Main(string[] args) { ep = new IPEndPoint(0, 12003); a = new Acceptor(new DefaultServiceHandlerFactory()); a.open(ep); a.accept(); //wait for shutdown System.Threading.AutoResetEvent ev = new System.Threading.AutoResetEvent(false); ev.WaitOne(); }
/// <summary> /// Deletes the associeted user from acceptor record. /// </summary> /// <param name="Acceptor">The acceptor.</param> /// <returns>True if deleted or false if there is no associeted user. </returns> public bool DeleteDependentUser(Acceptor Acceptor) { if (Acceptor.User != null) { context.Users.Attach(Acceptor.User); context.Users.Remove(Acceptor.User); context.SaveChanges(); return(true); } else { return(false); } }
/// <summary> /// Adds or edits the <paramref name="Acceptor"/> to the db. /// </summary> /// <param name="Acceptor">The donate.</param> /// <returns>ID of added of edited acceptor.</returns> public int CreateAcceptor(Acceptor Acceptor) { if ((Acceptor.User.Id == 0) && (context.Users.FirstOrDefault(x => x.Login == Acceptor.User.Login) != default(User))) { return(0); } context.Entry(Acceptor).State = Acceptor.Id == 0 ? EntityState.Added : EntityState.Modified; context.SaveChanges(); return(Acceptor.Id); }
private void init(int port) { lock (this) { if (!initDone) { connections = new Dictionary <String, OtpCookedConnection>(); sched = new OtpActorSched(); mboxes = new Mailboxes(this, sched); acceptor = new Acceptor(this, port); initDone = true; } } }
private static void Configurate() { using (Config config = new Config(@"..\DataSvr\" + Program.ConfigurationFile)) { Name = Program.ConfigurationFile.Replace(".img", ""); Port = config.GetUShort("", "port"); AdminPort = config.GetUShort("", "adminPort"); IPAddress ipAddress; string ipString = config.GetString("", "PublicIP"); if (!IPAddress.TryParse(ipString, out ipAddress)) { ipAddress = Dns.GetHostEntry(ipString).AddressList[0]; } PublicIP = ipAddress; PrivateIP = IPAddress.Parse(config.GetString("", "PrivateIP")); List <string> worldNames = config.GetBlocks("center", true); foreach (string worldName in worldNames) { World world = new World(); world.Name = worldName; world.ID = config.GetByte(worldName, "world"); world.Channels = config.GetByte(worldName, "channelNo"); Worlds.Add(world.ID, world); } } using (Config config = new Config(@"..\DataSvr\Database.img")) { string host = config.GetString("", "Host"); string schema = config.GetString("", "Schema"); string username = config.GetString("", "Username"); string password = config.GetString("", "Password"); Database = new Database(username, password, schema, host); } LoginAcceptor = new Acceptor(Port); LoginAcceptor.OnClientAccepted += new Action <Socket>(OnClientConnected); LoginAcceptor.Start(); }
public void Should_accept_the_value() { var acceptor = new Acceptor<string>(_serviceId) { Bus = _bus, }; InboundMessageHeaders.SetCurrent(x => { x.ReceivedOn(_bus); x.SetObjectBuilder(_builder); x.SetResponseAddress("loopback://localhost/queue"); }); Prepare<string> prepare = new Prepare<string> { BallotId = 1, CorrelationId = _serviceId, LeaderId = _leaderId, }; acceptor.RaiseEvent(Acceptor<string>.Prepare, prepare); acceptor.CurrentState.ShouldEqual(Acceptor<string>.Prepared); var accept = new Accept<string> { BallotId = 1, CorrelationId = _serviceId, LeaderId = _leaderId, Value = "Chris", }; acceptor.RaiseEvent(Acceptor<string>.Accept, accept); acceptor.CurrentState.ShouldEqual(Acceptor<string>.SteadyState); acceptor.Value.ShouldEqual(accept.Value); acceptor.BallotId.ShouldEqual(accept.BallotId); _endpoint.VerifyAllExpectations(); }
/// <summary> Accepts new connections on underlying ServerSocket, replacing /// any existing socket with the new one, blocking until a connection /// is available. See {@link DualTransportConnector} for a method of /// connecting two <code>TransportLayer</code>s in a way that avoids deadlock. /// /// </summary> /// <seealso cref="Genetibase.NuGenHL7.protocol.StreamSource.connect()"> /// </seealso> public override void connect() { Acceptor a = new Acceptor(myServerSocket, myExpectedAddress); mySocket = a.waitForSocket(); }
internal WSAcceptor(WSEndpoint endpoint, ProtocolInstance instance, Acceptor del) { _endpoint = endpoint; _instance = instance; _delegate = del; }
private void InitBlock(Genetibase.NuGenHL7.protocol.impl.NuGenServerSocketStreamSource.Acceptor a, System.Net.Sockets.TcpListener theServer, System.String theAddress, Acceptor enclosingInstance) { this.a = a; this.theServer = theServer; this.theAddress = theAddress; this.enclosingInstance = enclosingInstance; }
private void init(bool acceptConnections, int port) { lock(this) { if (!initDone) { connections = new System.Collections.Hashtable(17, (float) 0.95); mboxes = new Mailboxes(this); if (acceptConnections) acceptor = new Acceptor(this, port); listenPort = port; initDone = true; } } }
/* * When a node instance is created is started with acceptConnections set to false * then no incoming connections are accepted. This method allows to begin * accepting connections. **/ public bool startConnectionAcceptor() { if (acceptor != null) return true; else if (!initDone) return false; lock (this) { if (acceptor != null) acceptor = new Acceptor(this, listenPort); } return true; }
public override IceInternal.Acceptor acceptor(ref IceInternal.EndpointI endpoint, string adapterName) { Acceptor p = new Acceptor(_endpoint.acceptor(ref endpoint, adapterName)); endpoint = new EndpointI(endpoint); return p; }
private void init(int port) { lock (this) { if (!initDone) { connections = new Dictionary<String, OtpCookedConnection>(); sched = new OtpActorSched(); mboxes = new Mailboxes(this, sched); acceptor = new Acceptor(this, port); initDone = true; } } }
public AnonymousClassRunnable(Genetibase.NuGenHL7.protocol.impl.NuGenServerSocketStreamSource.Acceptor a, System.Net.Sockets.TcpListener theServer, System.String theAddress, Acceptor enclosingInstance) { InitBlock(a, theServer, theAddress, enclosingInstance); }