protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); Platform.Init(this, savedInstanceState); SetContentView(Resource.Layout.Main); var sendButton = FindViewById<Button>(Resource.Id.send_button); MessageTextView = FindViewById<EditText>(Resource.Id.message_text_view); var messagesRecyclerView = FindViewById<RecyclerView>(Resource.Id.messages_recycler_view); Messages = new ObservableCollection<string>(); messagesRecyclerView.SetLayoutManager(new LinearLayoutManager(this)); messagesRecyclerView.SetAdapter(new MessagesAdapter(messagesRecyclerView, Messages)); sendButton.Click += OnSend; NetworkComms.AppendGlobalIncomingPacketHandler<string>("Chat", HandleChatConnection); Connection.StartListening(ConnectionType.TCP, new IPEndPoint(IPAddress.Any, 49999)); PeerDiscoveryService = new PeerDiscoveryService(new UdpBroadcastService()); PeerDiscoveryService.StartListening(OnPeerDiscovered); PeerDiscoveryService.StartSending(DeviceInfo.Name); Timer.Elapsed += CheckExpiredNodes; Timer.Start(); }
public override void ViewDidLoad() { base.ViewDidLoad(); UIKeyboard.Notifications.ObserveDidShow(OnKeyboardDidShow); UIKeyboard.Notifications.ObserveWillHide(OnKeyboardWillHide); _messageTextField.Delegate = this; _tableView.RowHeight = UITableView.AutomaticDimension; _tableView.EstimatedRowHeight = UITableView.AutomaticDimension; _tableView.RegisterNibForCellReuse(MessageCell.Nib, MessageCell.Key); _tableView.Source = new MessagesTableSource(_tableView, Messages); _tableView.ReloadData(); NetworkComms.AppendGlobalIncomingPacketHandler <string>("Chat", HandleChatConnection); Connection.StartListening(ConnectionType.TCP, new IPEndPoint(IPAddress.Any, 49999)); PeerDiscoveryService = new PeerDiscoveryService(new UdpBroadcastService()); PeerDiscoveryService.StartListening(OnPeerDiscovered); PeerDiscoveryService.StartSending(DeviceInfo.Name); Timer.Elapsed += CheckExpiredNodes; Timer.Start(); }