-
Notifications
You must be signed in to change notification settings - Fork 5
first try gxs chess #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
| ChatId chatId = mChatWidget->getChatId(); | ||
| if (chatId.isDistantChatId()) { | ||
| RsGxsId distId = chatId.toDistantChatId(); | ||
| rsRetroChess->requestGxsTunnel(distId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Incorrect: if the chat id is a distant chat Id, then there is already a tunnel ;-)
| ui->friendSelectionWidget->setModus(FriendSelectionWidget::MODUS_SINGLE); | ||
| ui->friendSelectionWidget->setShowType(FriendSelectionWidget::SHOW_SSL); | ||
|
|
||
| connect(mNotify, SIGNAL(gxsTunnelOpened(RsGxsId)), this, SLOT(onGxsTunnelOpened(RsGxsId))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't use mNotify (I suppose it's a copy of the notify system of feedreader?). It's more practical to register your own service ID in rsEvents (there's a method for that) and then capture your own events. No need to modify rseventtypes.h
Doing it this way will avoid all these connect and slots in Qt.
| max=0; | ||
| texp = new int[60]; | ||
|
|
||
| setGeometry(0,0,1370,700); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
explicit sizes = bad idea. Use some constant times the font size.
| DistantChatPeerId tunnelId; | ||
|
|
||
| // Use initiateDistantChatConnexion to ensure the tunnel exists | ||
| if(!rsMsgs->initiateDistantChatConnexion(gxs_id, fromGxsId, tunnelId, error_code)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The whole process here is wrong: tunnel request should be done async. What you should do is:
Method 1:
1.a - open a tunnel using mGxsTunnel:
mGxsTunnels->requestSecuredTunnel(to_gxs_id,from_gxs_id,tunnel_id,RETRO_CHESS_GXS_TUNNEL_SERVICE_ID,error_code)
1.b - wait for the tunnel to be established (using an async method) and test the status using
mGxsTunnels->getTunnelInfo(RsGxsTunnelId(tunnel_id),tinfo))
1.c - once the tunnel is established, use it to send/recv chess moves, player states, etc
OR
Method 2:
2.a - register p3RetroChess as a GxsTunnel:
RsGxsNetTunnelService::registerSearchableService(retro chess service)
2.b - call requestDistantPeers() with some fake group Id (can be anything, but mostly something that your friends will know to answer. It can be a constant => all chess players will answer, or a code => only the ones with the invite will answer). The service will then manage "virtual peers" automatically for each of them.
2.c - use sendTunnelData() to send to each virtual peer you want and reimplement receiveTunnelData to receive data.
The main difference is that: with method 1 you do the tunnel and peer management yourself. With method 2, the GxsNetTunnelService does it all for you: you just need to add the code in p3RetroChess to answer the calls from GxsNetTunnelService, and it will show you which peers want to play. You can then send data to them directly through GxsNetTunnelService.
No description provided.