private static T CreateChannel <T>(string serviceAddress, IClientCallBack handler) { NetTcpBinding binding = new NetTcpBinding(SecurityMode.None); DuplexChannelFactory <T> factory = new DuplexChannelFactory <T>(new InstanceContext(handler), binding, serviceAddress); return(factory.CreateChannel()); }
public ClientLauncher(IClientCallBack clientCallBack, MainForm ownerForm) { callback = clientCallBack; this.ownerForm = ownerForm; SetServerInstance(); authorization = new Authorization(); }
public void addClient(DTO_Player player, IClientCallBack client) { if (clients.ContainsKey(player.Id)) { clients[player.Id] = client; } else { clients.Add(player.Id, client); } }
public ResponseTarsConvert(ITarsConvert <short> shortConvert, ITarsConvert <int> intConvert, ITarsConvert <byte> byteConvert, ITarsConvert <string> stringConvert, IDictionaryInterfaceTarsConvert <string, string> dictConvert, ITarsConvert <IByteBuffer> bufferConvert, ITarsConvertRoot convertRoot, IRpcMetadata rpcMetadata, ITarsHeadHandler headHandler, IClientCallBack clientCallBack) { this.shortConvert = shortConvert; this.intConvert = intConvert; this.byteConvert = byteConvert; this.stringConvert = stringConvert; this.dictConvert = dictConvert; this.bufferConvert = bufferConvert; this.convertRoot = convertRoot; this.rpcMetadata = rpcMetadata; this.headHandler = headHandler; this.clientCallBack = clientCallBack; }
public BllUser ConnectToServerAndSignIn(string ip, IClientCallBack clientCallBack, BllUser user) { try { ConnectToServer(); return(SignIn(user)); } catch (ConnectionFailedException ex) { throw ex; } catch (UserIsNullException ex) { throw ex; } }
public void RegisterClient(int gameID, DTO_Player player) { IClientCallBack client = OperationContext.Current.GetCallbackChannel <IClientCallBack>(); bool isRegisterSucceed = true; //find game for this player var query = from gp in db.GamePlays where gp.GAME_ID == gameID select gp; //get game GamePlay gpFromDB = null; foreach (GamePlay gamePlay in query) { gpFromDB = gamePlay; } //check if this game allready exist in games list, if exist its just add to it the clien // if not create game if (games.ContainsKey(gpFromDB.GAME_ID)) { ////check if this client allready registared //if (games[gpFromDB.GAME_ID].isClientAllredyConnected(player)) //{ // isRegisterSucceed= false; // client.NotifyRegistarClientStatus(isRegisterSucceed); // return; //} //else //{ games[gpFromDB.GAME_ID].addClient(player, client); // } } else { Game g = new Game(gpFromDB.GAME_ID); g.addClient(player, client); games.Add(gpFromDB.GAME_ID, g); } games[gpFromDB.GAME_ID].CheckForGameStart(client); client.NotifyRegistarClientStatus(isRegisterSucceed); }
// checks whenever client is connected and ready to start playing public void CheckForGameStart(IClientCallBack client) { if (clients.Count == Application_Constants.nPlayersForGameStart) { readyClients = 0; foreach (KeyValuePair <int, IClientCallBack> pair in clients) { try { pair.Value.CheckClientReady(); } catch (Exception) { } } } }
public UdpClient(IServiceProvider provider, RpcConfiguration configuration, IDecoder <IByteBuffer> decoder, IEncoder <IByteBuffer> encoder, IClientCallBack callBack) { this.encoder = encoder; bootstrap .Group(group) .Channel <SocketDatagramChannel>() .LocalAddress(configuration.UdpLocalPort) .Option(ChannelOption.SoBroadcast, true) .Handler(new ActionChannelInitializer <IChannel>(channel => { var lengthFieldLength = configuration.LengthFieldLength; channel.Pipeline.AddLast(new UdpClientHandler(provider.GetRequiredService <ILogger <UdpClientHandler> >())); channel.Pipeline.AddLast(new LengthFieldBasedFrameDecoder(ByteOrder.BigEndian, configuration.MaxFrameLength, 0, lengthFieldLength, 0, lengthFieldLength, true)); channel.Pipeline.AddLast(new ResponseDecoder(decoder), new DatagramPacketEncoder <IByteBuffer>(new UdpLengthFieldPrepender(lengthFieldLength)), new DotNettyClientHandler(callBack)); })); }
public void RegisterForUpdate(string ticker) { Worker worker = null; if (!workers.ContainsKey(ticker)) { worker = new Worker(); worker.ticker = ticker; worker.workerProcess = new Update(); worker.workerProcess.ticker = ticker; workers[ticker] = worker; Thread thread = new Thread(new ThreadStart(worker.workerProcess.SendUpdateToClient)); thread.IsBackground = true; thread.Start(); } worker = (Worker)workers[ticker]; IClientCallBack clientCallBack = OperationContext.Current.GetCallbackChannel <IClientCallBack>(); lock (worker.workerProcess.callBacks) { worker.workerProcess.callBacks.Add(clientCallBack); } }
private void RegisterClient(string key) { if (key != null && key != "") { try { IClientCallBack callback = OperationContext.Current.GetCallbackChannel <IClientCallBack>(); lock (locker) { //remove the old client if (Clients.Keys.Contains(key)) { Clients.Remove(key); } Clients.Add(key, callback); } } catch (Exception ex) { throw new Exception("RegisterClient", ex); } } }
public IBusinessService GetServerMethods(IClientCallBack handler, string hostIP) { return(SourceChannel = CreateChannel <IBusinessService>("net.tcp://" + hostIP + "/ServerInterface/", handler)); }
public string RegisterClient() { IClientCallBack callback = OperationContext.Current.GetCallbackChannel <IClientCallBack>(); return(db.RegisterClient(callback.SendMessage)); }
public LibuvTcpClient(RpcConfiguration configuration, IDecoder <IByteBuffer> decoder, IEncoder <IByteBuffer> encoder, IClientCallBack callBack) { this.encoder = encoder; bootstrap .Group(group) .Channel <TcpSocketChannel>() .Option(ChannelOption.TcpNodelay, true) .Handler(new ActionChannelInitializer <IChannel>(channel => { var lengthFieldLength = configuration.LengthFieldLength; channel.Pipeline.AddLast(new LengthFieldBasedFrameDecoder(ByteOrder.BigEndian, configuration.MaxFrameLength, 0, lengthFieldLength, 0, lengthFieldLength, true)); channel.Pipeline.AddLast(new ResponseDecoder(decoder), new LengthFieldPrepender(lengthFieldLength), new DotNettyClientHandler(callBack)); })); }
public ServerInstance(string ip, IClientCallBack clientCallBack) { this.ip = ip; this.clientCallBack = clientCallBack; }
public RpcClientFactory(IEnumerable <IRpcClient> rpcClients, RpcConfiguration configuration, IClientCallBack callBack) { this.configuration = configuration; this.callBack = callBack; clients = rpcClients.ToDictionary(i => i.Protocol); }
private IBusinessService GetServerInstanceUsingIp(string ip, IClientCallBack clientCallBack) { return(ServiceChannelMakerSingleton.Instance.GetServerMethods(clientCallBack, ip)); }
public DotNettyClientHandler(IClientCallBack callBack) { this.callBack = callBack; }