From 6f05c6f3e17c012a57edde8154060558719e2fee Mon Sep 17 00:00:00 2001 From: Laky64 Date: Thu, 18 Apr 2024 02:12:12 +0200 Subject: [PATCH] Updated Go Example --- examples/go/main.go | 1 + examples/go/ntgcalls/ntgcalls.go | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/examples/go/main.go b/examples/go/main.go index 03e567b4..bbb4027f 100644 --- a/examples/go/main.go +++ b/examples/go/main.go @@ -20,6 +20,7 @@ func main() { }) _ = mtproto.Start() // Choose between outgoingCall or joinGroupCall + fmt.Println(client.Calls()) //outgoingCall(client, mtproto, "@PyTgCallsVideoBeta") //joinGroupCall(client, mtproto, "@pytgcallschat") client.OnStreamEnd(func(chatId int64, streamType ntgcalls.StreamType) { diff --git a/examples/go/ntgcalls/ntgcalls.go b/examples/go/ntgcalls/ntgcalls.go index f2c7e176..016a5096 100644 --- a/examples/go/ntgcalls/ntgcalls.go +++ b/examples/go/ntgcalls/ntgcalls.go @@ -187,7 +187,8 @@ func (ctx *Client) CreateP2PCall(chatId int64, dhConfig DhConfig, gAHash []byte, var buffer [32]C.uint8_t size := C.int(len(buffer)) gAHashC, gAHashSize := parseBytes(gAHash) - C.ntg_create_p2p(C.uint32_t(ctx.uid), C.int64_t(chatId), dhConfig.ParseToC(), gAHashC, gAHashSize, desc.ParseToC(), &buffer[0], size, f.ParseToC()) + dhConfigC := dhConfig.ParseToC() + C.ntg_create_p2p(C.uint32_t(ctx.uid), C.int64_t(chatId), &dhConfigC, gAHashC, gAHashSize, desc.ParseToC(), &buffer[0], size, f.ParseToC()) f.wait() return C.GoBytes(unsafe.Pointer(&buffer[0]), size), parseErrorCode(*f.errCode) } @@ -325,6 +326,9 @@ func (ctx *Client) Calls() map[int64]StreamStatus { _ = C.ntg_calls_count(C.uint32_t(ctx.uid), &callSize, f.ParseToC()) f.wait() f = CreateFuture() + if callSize == 0 { + return mapReturn + } buffer := make([]C.ntg_call_struct, callSize) C.ntg_calls(C.uint32_t(ctx.uid), &buffer[0], callSize, f.ParseToC()) f.wait()