How to build a simple 2-player game, communicating over the internet, with no custom code on any server?

StackOverflow https://stackoverflow.com/questions/2144287

  •  23-09-2019
  •  | 
  •  

문제

How can I build a simple 2-player game, that communicates over the internet?

I need to solve the problems of:

  • lookup or rendezvous - two players want to find each other.

  • ongoing communications. Either player can initiate an action that requires delivering information to the other side, in a reasonbly quick timeframe (IM-type latency, not email-type latency).

In this regard, I suppose it is equivalent to a 2-way chat, where people want to be able to find each other, and then also, once paired up, intercommunicate.

Further requirements:

  1. for now, assume the endpoints are Windows OS, relatively recent.

  2. assume neither endpoint machine is directly accessible from the internet. Assume they are client machines, hidden behind firewalls that block incoming requests. The machines can make outbound requests. (say, over HTTP, but TCP is also fine)

  3. communication should be private. For simplicity, let's say there's a shared secret already in place, and the endpoints are able to do AES. I guess what I mean by this is, any intermediary should not need to decrypt the message packets. The decryption will happen only at the endpoints.

  4. all custom code should run only on the client PCs.

  5. Assume there is no server in the internet that is under my control.

  6. I'm happy to use third-party servers to facilitate intercommunication, like an IM server or something, as long as it's free, and I am not required to install custom code on it.


What APIs are available to facilitate this design?

Can I do this with IM APIs? WCF? Are there WCF Channels for Windows Messenger?

What protocols? HTTP? I have this tagged as "peer-to-peer" but I mean that virtually; there's no hard requirement for a formal p2p protocol.

What message formats would you use?


EDIT

To clarify the requirements around servers, what I want is NO SERVER UNDER MY CONTROL. And NONE OF MY CUSTOM CODE ON ANY SERVER. That is not the same as "No server".

Think of it this way: I can send an email over SMTP, using custom code that I write on the sending and receiving side. My custom code can connect via a free SMTP server intermediary. This would require no installation of code on the SMTP server. This is something like what I want, but SMTP is not acceptable, because of the latency.

EDIT2
I also found this: library for Instant Messaging, like libpurple, but written in C#


ANSWER

I can do what I want, using libraries for IM frameworks. One simple way to do it using Windows Live Messenger is to use the Messenger Activity SDK. This proves the concept, but is not really a general solution. But, similar things can be accomplished with the IM libraries for various messenger systems, like libpurple, or using libs for IRC channels. In all these cases, the IM servers act as the firewall-penetrating communications infrastructure.

도움이 되었습니까?

해결책

libpurple along with otr can give you the privacy-over-IM such an application would need.

다른 팁

는 실제 분류 중에 사용중인 그리드 검색에서 동일한 데이터를 사용하는 것이 좋습니다.

분류자를 교육 (피팅)을 위해이 데이터를 사용하는 것은 괜찮습니다. StratifiedKFold가 수행 한 횡단 유효성 검사는 HyperParameters (알고리즘 설정)를 최적화하는 동안 유효성 검사 세트를 보유 할 수있는 충분한 데이터가없는 상황을 대상으로합니다. 또한 유효성 검사 세트 스플리터를 만들고 Scikit-Learn의 내장 된 교차 유효성 검사에 의존하기를 원하는 경우에도 사용할 수 있습니다.)

refit to GridSearchCV 옵션은 상호 유효성 검사를 사용하여 최적의 설정을 찾은 후 전체 교육 세트에서 추정기를 트리밍합니다.

이미 레이블이 있으므로 검색되거나 훈련 된 데이터에 대한 훈련 된 분류자가 적용 적용됩니다. 분류 자의 공식 평가를 원한다면, 처음부터 테스트 세트를 누른 상태에서 모든 그리드 검색, 유효성 검사 및 피팅을 완료 할 때까지 다시 터치하지 않아야합니다.

Every two-player game must have some type of server environment by the basic need of having to communicate between two clients/players at the very least. Keep in mind, each of the clients/players can also act as its own server to communicate with other linked clients. But the need to keep tabs on all clients/players at any given time and the need to facilitate searching of other clients/players inherently requires some type of server environment to begin with.

You could setup a message board on one of the free message board servers so that players can find each other. You'll probably want to encourage them to use private messages to exchange IP addresses. Then, use a protocol that connects using IP addresses. Good luck with that. Firewalls make it a pain.

Then, of course, one machine of the pair would need to act as server, the other as client. Your software must contain both sets of code. I've written such a game and can tell you that the communication code gets a little confusing.

I can tell you right now that you'd be much happier in life if you wrote a web service to facilitate communication. But, then, you'd need a server for that.

Good luck. You're going to need it.

OR, you could just write a game for an IM client, like Microsoft Messenger. I've seen games for that one, so I know it can be done.

As somebody has said, it may not yet possible to do so if you don't have any mediated server between 2 players. As you're happy to use third party server, I suggest that you build your system using Google App Engine + XMPP over HTTP. It works nicely over internet and behind firewall. And yet it's free (as long as your system doesn't grow out of GAE quota).

Peer to peer is out due to your firewall constraint. This doesn't really work easily for directory services anyway.

The next easiest method I would use is to toss up a very simple CGI server script on one of the numerous super cheap web hosting sites. It seems that you don't want to go this route. Is there some particular reason? 100 lines of code and a super cheap server should give you everything you're asking for and more.

I suppose you could hook into some sort of third party chat library thing. I don't know about the current IM protocols, but good old IRC and a separate channel for your game would work. You even could cobble something together using FTP. BLOG comments on a free blog site would work too. The question is why?

These are all kludges. They get the job done in obtuse, inelegant, and poorly scaling ways.

I urge you to reconsider the web server solution.

You have a lot of conflicting requirements. Both clients behind a firewall blocking incoming requests pretty much means they can't do peer-2-peer since neither machine can act as the server, and you will need to have a transport server in the middle somewhere routing messages to each client. Right now what you are asking is pretty much not possible given the no server requirement.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top