Example #1
0
// Create a Go Channel struct, and prepare internal CGO references / observers.
// Expects cDC to be a pointer to a CGO_Channel object, which ultimately points
// to a DataChannelInterface*.
// The most reasonable place for this to be created is from PeerConnection,
// which is not available in the subpackage.
func NewChannel(cDC unsafe.Pointer) *Channel {
	if nil == cDC {
		return nil
	}
	dc := new(Channel)
	dc.cgoChannel = (C.CGO_Channel)(cDC)
	dc.BinaryType = "blob"
	// "Observer" is required for attaching callbacks correctly.
	C.CGO_Channel_RegisterObserver(dc.cgoChannel, unsafe.Pointer(dc))
	return dc
}
Example #2
0
// Create a Go Channel struct, and prepare internal CGO references / observers.
// The most reasonable place for this to be created is from PeerConnection,
// which is not available in the subpackage.
func NewDataChannel(o unsafe.Pointer) *DataChannel {
	if o == nil {
		return nil
	}
	c := new(DataChannel)
	c.index = DCMap.Set(c)
	c.BinaryType = "blob"
	cgoChannel := C.CGO_Channel_RegisterObserver(o, C.int(c.index))
	c.cgoChannel = (C.CGO_Channel)(cgoChannel)
	return c
}