private static void DoOpen(C4Socket *socket, C4Address *address, C4Slice options) { var builder = new UriBuilder { Host = address->hostname.CreateString(), Scheme = address->scheme.CreateString(), Port = address->port, Path = address->path.CreateString() }; Uri uri; try { uri = builder.Uri; } catch (Exception) { Native.c4socket_closed(socket, new C4Error(C4ErrorCode.InvalidParameter)); return; } if (uri == null) { Native.c4socket_closed(socket, new C4Error(C4ErrorCode.InvalidParameter)); return; } var opts = FLSliceExtensions.ToObject(NativeRaw.FLValue_FromTrustedData((FLSlice)options)) as Dictionary <string, object>; var replicationOptions = new ReplicatorOptionsDictionary(opts); var socketWrapper = new WebSocketWrapper(uri, socket, replicationOptions); var id = Interlocked.Increment(ref _NextID); socket->nativeHandle = (void *)id; Sockets[id] = socketWrapper; socketWrapper.Start(); }
private static void DoOpen(C4Socket *socket, C4Address *address, FLSlice options, void *context) { var builder = new UriBuilder { Host = address->hostname.CreateString(), Scheme = address->scheme.CreateString(), Port = address->port, Path = address->path.CreateString() }; Uri uri; try { uri = builder.Uri; } catch (Exception) { Native.c4socket_closed(socket, new C4Error(C4ErrorCode.InvalidParameter)); return; } if (uri == null) { Native.c4socket_closed(socket, new C4Error(C4ErrorCode.InvalidParameter)); return; } var opts = FLSliceExtensions.ToObject(NativeRaw.FLValue_FromData((FLSlice)options, FLTrust.Trusted)) as Dictionary <string, object>; var replicationOptions = new ReplicatorOptionsDictionary(opts); var id = Interlocked.Increment(ref _NextID); Native.c4Socket_setNativeHandle(socket, (void *)id); var socketWrapper = new WebSocketWrapper(uri, socket, replicationOptions); var replicator = GCHandle.FromIntPtr((IntPtr)context).Target as Replicator; replicator?.WatchForCertificate(socketWrapper); replicator?.CheckForCookiesToSet(socketWrapper); Sockets.AddOrUpdate(id, socketWrapper, (k, v) => socketWrapper); socketWrapper.Start(); }
internal void CheckForCookiesToSet(WebSocketWrapper wrapper) { wrapper.CookiesToSetReceived += OnCookiesToSetReceived; }
internal void WatchForCertificate(WebSocketWrapper wrapper) { wrapper.PeerCertificateReceived += OnTlsCertificate; }