public Bookie(Gambler connectingGambler, IPAddress address, int portNo) : base(address, portNo) { _listOfBets = new ObservableCollection<Bet>(); _listOfMatches = new ObservableCollection<Match>(); _listOfWinnings = new ObservableCollection<Winnings>(); this._connectingGambler = connectingGambler; Mode = JSON_RPC_Server.ServiceMode.RELIABLE; Connection = new RPC.BookieConnection(connectingGambler, address.ToString(), portNo); //Subscribe to the collection, so any new messages are processed this._connectingGambler.Connection.Service.getList().CollectionChanged += handleUpdates; Connection.establishSocketConnection(); this.ID = Connection.sendConnect(); if (this.ID == string.Empty) throw new Controller.ConnectionFailed(); Connected = true; //We'll retrieve data from the bookie, let's make sure we're up to date and collect any previous winnings this.refreshMatches(); this._connectingGambler.addMoney(this.Connection.getPreviousWinnings()); }
public GamblerServer(Gambler gambler) { this.gambler = gambler; jsonSerializer = new JsonSerializer(); }