/// <summary> /// Initializes a new instance of the <see cref="PeerNet.DataConnection"/> class. /// </summary> /// <param name="peer">Peer to connect to.</param> /// <param name="provider">This Peer.</param> /// <param name="dataConnectionOptions">an instance of the DataConnectionOptions class.</param> public DataConnection (Peer peer, Peer provider, DataConnectionOptions dataConnectionOptions) { Type = "data"; this.Peer = peer; this.Provider = provider; this.Id = "dc_" + Util.token; this.DataConnectionOptions = dataConnectionOptions; negotiator = Negotiator.GetNegotiator (); NegotiatorOptions negotiatorOptions = new NegotiatorOptions (); negotiatorOptions.Originator = true; negotiator.StartConnection (this, negotiatorOptions, provider.context); }
protected override void OnCreate (Bundle bundle) { base.OnCreate (bundle); // Set our view from the "main" layout resource SetContentView (Resource.Layout.Main); // Get our button from the layout resource, // and attach an event to it Button button = FindViewById<Button> (Resource.Id.MyButton); textView = FindViewById<TextView> (Resource.Id.textView1); EditText editText = FindViewById<EditText> (Resource.Id.editText1); button.Click += delegate { targetPeer = editText.Text; PeerNet.DataConnectionOptions dataConnectionOptions = new DataConnectionOptions (null, null, DataConnectionOptions.SerializationType.json, true); dataConnection = peer.Connect (targetPeer, dataConnectionOptions); dataConnection.DataConnectionOpened += DataConnection_DataConnectionOpened; }; Button sendButton = FindViewById<Button> (Resource.Id.button1); sendButton.Click += SendButton_Click; peer = new Peer (null, new PeerOptions (null, null, "ytgklpf684u0udi", null, null), this); peer.PeerConnected += Peer_PeerConnected; }
public DataConnection Connect (string peer, DataConnectionOptions options) { Peer peerToConnect = new Peer (peer); DataConnection dataConnection = new DataConnection (peerToConnect, this, options); this.connections.Add (dataConnection); return dataConnection; }