mirror of
https://github.com/logos-messaging/logos-chat.git
synced 2026-05-17 18:09:57 +00:00
Fix examples
This commit is contained in:
parent
bcfd98eb2a
commit
cc7907d9ab
@ -24,7 +24,7 @@ proc main() {.async.} =
|
|||||||
await chatClient.start()
|
await chatClient.start()
|
||||||
|
|
||||||
info "EchoBot started"
|
info "EchoBot started"
|
||||||
info "Invite", link=chatClient.createIntroBundle().toLink()
|
info "Invite", link=chatClient.createIntroBundle()
|
||||||
|
|
||||||
when isMainModule:
|
when isMainModule:
|
||||||
waitFor main()
|
waitFor main()
|
||||||
|
|||||||
@ -5,8 +5,6 @@ import strformat
|
|||||||
import chat
|
import chat
|
||||||
import content_types
|
import content_types
|
||||||
|
|
||||||
# TEsting
|
|
||||||
import ../src/chat/crypto
|
|
||||||
|
|
||||||
|
|
||||||
proc getContent(content: ContentFrame): string =
|
proc getContent(content: ContentFrame): string =
|
||||||
@ -35,39 +33,38 @@ proc main() {.async.} =
|
|||||||
var saro = newClient(waku_saro, Identity(name: "saro", privateKey: sKey))
|
var saro = newClient(waku_saro, Identity(name: "saro", privateKey: sKey))
|
||||||
var raya = newClient(waku_raya, Identity(name: "raya", privateKey: rKey))
|
var raya = newClient(waku_raya, Identity(name: "raya", privateKey: rKey))
|
||||||
|
|
||||||
var ri = 0
|
# Wire Saro Callbacks
|
||||||
# Wire Callbacks
|
saro.onNewMessage(proc(convo: Conversation, msg: ReceivedMessage) {.async, closure.} =
|
||||||
saro.onNewMessage(proc(convo: Conversation, msg: ReceivedMessage) {.async.} =
|
|
||||||
let contentFrame = msg.content.fromBytes()
|
let contentFrame = msg.content.fromBytes()
|
||||||
echo " Saro <------ :: " & getContent(contentFrame)
|
notice " Saro <------ ", content = getContent(contentFrame)
|
||||||
await sleepAsync(5000.milliseconds)
|
await sleepAsync(1000.milliseconds)
|
||||||
discard await convo.sendMessage(initTextFrame("Ping").toContentFrame().toBytes())
|
discard await convo.sendMessage(initTextFrame("Ping").toContentFrame().toBytes())
|
||||||
|
)
|
||||||
)
|
|
||||||
|
|
||||||
saro.onDeliveryAck(proc(convo: Conversation, msgId: string) {.async.} =
|
saro.onDeliveryAck(proc(convo: Conversation, msgId: string) {.async.} =
|
||||||
echo " Saro -- Read Receipt for " & msgId
|
notice " Saro -- Read Receipt for ", msgId= msgId
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# Wire Raya Callbacks
|
||||||
|
var i = 0
|
||||||
|
raya.onNewConversation(proc(convo: Conversation) {.async.} =
|
||||||
|
notice " ------> Raya :: New Conversation: ", id = convo.id()
|
||||||
|
discard await convo.sendMessage(initTextFrame("Hello").toContentFrame().toBytes())
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
raya.onNewMessage(proc(convo: Conversation,msg: ReceivedMessage) {.async.} =
|
raya.onNewMessage(proc(convo: Conversation,msg: ReceivedMessage) {.async.} =
|
||||||
let contentFrame = msg.content.fromBytes()
|
let contentFrame = msg.content.fromBytes()
|
||||||
echo fmt" ------> Raya :: from:{msg.sender} " & getContent(contentFrame)
|
notice " ------> Raya :: from: ", content= getContent(contentFrame)
|
||||||
await sleepAsync(500.milliseconds)
|
await sleepAsync(500.milliseconds)
|
||||||
discard await convo.sendMessage(initTextFrame("Pong" & $ri).toContentFrame().toBytes())
|
discard await convo.sendMessage(initTextFrame("Pong" & $i).toContentFrame().toBytes())
|
||||||
await sleepAsync(800.milliseconds)
|
await sleepAsync(800.milliseconds)
|
||||||
discard await convo.sendMessage(initTextFrame("Pong" & $ri).toContentFrame().toBytes())
|
discard await convo.sendMessage(initTextFrame("Pang" & $i).toContentFrame().toBytes())
|
||||||
await sleepAsync(500.milliseconds)
|
inc i
|
||||||
discard await convo.sendMessage(initTextFrame("Pong" & $ri).toContentFrame().toBytes())
|
|
||||||
inc ri
|
|
||||||
)
|
)
|
||||||
|
|
||||||
raya.onNewConversation(proc(convo: Conversation) {.async.} =
|
|
||||||
echo " ------> Raya :: New Conversation: " & convo.id()
|
|
||||||
discard await convo.sendMessage(initTextFrame("Hello").toContentFrame().toBytes())
|
|
||||||
)
|
|
||||||
raya.onDeliveryAck(proc(convo: Conversation, msgId: string) {.async.} =
|
raya.onDeliveryAck(proc(convo: Conversation, msgId: string) {.async.} =
|
||||||
echo " raya -- Read Receipt for " & msgId
|
echo " raya -- Read Receipt for " & msgId
|
||||||
)
|
)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user