Skip to content

Conversation

@defnax
Copy link
Collaborator

@defnax defnax commented Dec 25, 2025

No description provided.

@defnax defnax marked this pull request as draft December 25, 2025 16:20
@defnax defnax changed the title frist try gxs chess first try gxs chess Dec 27, 2025
ChatId chatId = mChatWidget->getChatId();
if (chatId.isDistantChatId()) {
RsGxsId distId = chatId.toDistantChatId();
rsRetroChess->requestGxsTunnel(distId);
Copy link
Collaborator

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)));
Copy link
Collaborator

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);
Copy link
Collaborator

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)) {
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants