public Protocol(int?port, PeerAddress[] potential_peers, Chat.NewMessage new_msg_action) { r = new Random(); ID = (ulong)(r.NextDouble() * ulong.MaxValue); com = new Communications(port); messages = new Messages(); tlv_utils = new TLV_utils(ID); p = new Peers(potential_peers, com, tlv_utils, messages); c = new Chat(com, tlv_utils, messages, p, new_msg_action); }
public Chat(Communications com, TLV_utils tlv_utils, Messages messages, Peers peers, NewMessage new_message_action) { r = new Random(); this.com = com; this.messages = messages; this.tlv_utils = tlv_utils; this.peers = peers; this.new_message_action = new_message_action; recent_messages = new Dictionary <MessageIdentifier, MessageFloodInfo>(); }
public Peers(PeerAddress[] potentialNeighbors, Communications com, TLV_utils tlv_utils, Messages messages) { this.potentialNeighbors = new Dictionary <PeerAddress, int>(); for (int i = 0; i < potentialNeighbors.Length; i++) { PeerAddress addr = potentialNeighbors[i]; // To be sure that initial addresses are IPv6 addr.ip = addr.ip.MapToIPv6(); this.potentialNeighbors[addr] = -1; // We associate -1 : we want to never delete inital potential neighbors from the list. } this.com = com; this.messages = messages; this.tlv_utils = tlv_utils; neighborsTable = new Dictionary <PeerAddress, PeerInfo>(); }