Golang - API architecture, sockets

Currently in dev of the API for my company, I have to make an API to sned some data to my Xamarin client. A part of the API is to make communicate a client with a “seller” which provide the service. The seller registers himself to a list of available seller and then wait a client. However, first problem: Do I have to make an infinite request and then wait a client? Or it’s better to just open a socket?. After a client is interested, the command begin but at a moment, the both will have to speak together… So I though about make request but because I don’t know in which sens will be the exchange, I think it’s to hard and then a “Socket” would be the better way to handle it.

Now I have a second problem that I don’t understand: How can I have 2 server at the same time? I mean, I need a server/API but I also need a socket, so how can I handle the second listener?

It’s my first API and honestly, I’m totaly stuck. I already though to stock each socket in the related seller elem (in my dynamic list), but my client aren’t in a special list, they just ask for services, then an exchange of request begin, but at the end I need communication and I can’t imagine the logic in my little mind…

This is the logic of the exchange:

But this way isn’t the best, in first for the notifications part… I think I’m totaly lost and my API isn’t right about the logic…

I think it would be better if the seller just registers itself with and open a socket, then when a client ask and get the list of seller, it chooses one and the communication switchs instantly by the socket. However for me, it brings one more time a new problem: Because the socket cannot be opened between two client (client/seller), I have to pass by the server, but how to organize that part of the API? Do I have to send to each one a listener as HttpAnswer or they have to make a request with a “token” to create a new channel or something like that?

Maybe I’m not logic and I think so, but at the moment, I’m totally stuck and not really sure about what I do and what I have to do…

Need help please

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.