def onmessage_cb(channel, datatype, data, length, userdata): if datatype == RTCDC_DATATYPE_STRING: message = ffi.cast("char *", data) message = ffi.string(message) message = message[:length].decode("UTF-8") if datatype == RTCDC_DATATYPE_BINARY: message = ffi.cast("char *", data) message = ffi.buffer(message, length)[:] if userdata: ffi.from_handle(userdata)._onMessage(message)
def generate_offer_sdp(self): offerSDP = lib.rtcdc_generate_offer_sdp(self.peer) offerSDP = ffi.string(offerSDP) return b64encode(offerSDP)
def oncandidate_cb(peer, candidate, userdata): candidate = ffi.string(candidate) ffi.from_handle(userdata)._onCandidate(peer, candidate)
def generate_local_candidate(self): candidateSDP = lib.rtcdc_generate_local_candidate_sdp(self.peer) candidateSDP = ffi.string(candidateSDP) return b64encode(candidateSDP)