I am making a game where to players play together in a game through internet,so i wanted to check to see if one of them left the game so i notify the other player .
currently i have written a code which runs every second on client side and sends a request to server but when ever it stops for 2 seconds then the player will be considered as "left the game" and the other player will get a response from server which tells it that the game stopped ,so as you can see there is a lot of requests from android client to server happening .
Is there anyway to do this better? someone told me socket programming may help but is it for this kind of works?i'm really used to using the volley library for android and sing it for requests
Have you thought of using socket.io instead of sending request from client side every time, socket.io would immediately know if somebody disconnects from the server as connection is persistent.
Related
I started with a application where you can chat.
Now im in the position to start with the chat.
The problem I'm facing is that I don't want to use
resources from "outside". With outside I mean:
Firebase, Socket.io and so on.
I do simply rent a webspace. And I'm asking you now,
how is it possible to realize an live chat without
using extern services like firebase.
Is it possible with only using an Webspace?
What is required to make an live chat?
And there comes the second question:
How do I realize to stay connected to a server to check if there is a new message without using much battery or network ressources?
I'm not asking without hardly trying by my self.
Two days ago I started with the research of possibility, but I didn't found anything which would work I guess.
Thanks folks...
You need to connect to the Web Server using a Socket and keep that connection open to receive new messages with little delay (see for example http://srchea.com/build-a-real-time-application-using-html5-websockets) This keeps the phone active and uses much battery.
The very purpose of Firebase is to bundle this work for all services which need this type of communication (E-Mail, Push messages of newspapers, Chats) such that the phone only has to query one server. Therefore, I see no way for you to find another solution which uses little battery.
Currently, I'm working on my new project - a (quite) simple game on Android allowing users to play with each other. One game is divided into few rounds, that users play separately. When one user has finished his round, application should send message to a server, which, in turn, should send notification to the other player with set of actions made by first player.
Beside that, players should be able to send invitations to the game to other players and server, for its own, should be able to send notifications, when, for example, user didn't make a move for a long time. (sort of reminders)
I'm wondering which technology/library/... I can use to make this work. I read a little bit about GCM, but I'm not sure it's good choice. I don't want my app to send some "pings" to server in every second/minute to check if it has something new happened. I want it to be as light and speed as possible.
Can you give me a hint?
Thanks in advance.
#Tomek,
First, probably you will will need to keep a persistent connection while the person is in the game to you server to have a minimal latency.
Second, you know java if you are writing on Android
Third, asynchronous event-driven server model might be a good choice.
I'd like to recommend you to take a look on netty
http://netty.io/
At the same time, Google has a multi-player API, but it is too vendor lock and the general idea behind is different
https://developers.google.com/games/services/common/concepts/realtimeMultiplayer
I am working on a game - it requires to implement offer-Wall.
The problem is from within the game I am not able to display the offer-Wall.
My game at the time of loading the splash makes some connections (login, creating sessions etc) with own game server. Once this is done im not able to display the offer-wall.
If I Comment the in-game server connections the offer-wall works good.
And the offe-rwall being used is NativeX (W3i earlier)
But I could display the same offer-wall correctly from another test App.
Seems like Once the game is connected to the game server, no other connections are alowed Or they are put on hold. Any help with this please.
Thanks in Advance.
The NativeX MonetizationSDK requires initialization on the UI Thread.
Make sure that after you are making the network calls to your server you get back on the UI Thread before initializing and calling the SDK.
I have three Android devices with the same app, but I need that the three devices start the app simultaneously.
I have a server too, and the app exchange data with this server (developed in NodeJS).
I thought that all devices can connect to the server and wait until a response. But I don't know how to do it with Node. I used clusters in Node but it didn't work, because I don't know how to synchronize all these 3 clusters.
How can I do that? Another idea?
Thank you.
Well, it's easy to implement with generic events in node.js. Create some special event, and keep requests without response until the event is triggered, what obviously happens when 3rd request is received. node.js is very powerful in that.
I am creating a simple android game that deals with multiplayer and connecting to server. This is what I want to achieve for my game.
Client sends keystroke movement to server.
Server accepts input, update the state and calculates and returns new position to client
Client gets new position and update the screen.
I already have some code written and so my one of my threads sends keystroke to server, waits for the new position, then update the screen. The thing is there is lag between the player's movement. I think it has to do with latency. I also tried two thread, one for sending/receiving data from server and another is updating the screen. But it didnt' solve my latency problem.
Can anyone suggest a good design for networking game?
Do I need to do early prediction?
Do I need separate thread for fetching data and rendering screen?
P.S.This is my first time creating a network game so i have no idea what im doing.
The structure I prefer to use is to have one thread updating graphics and logic on the client side, and then one thread receiving and sending data to the server. If you have problems with latency, there is a magic option which might solve it if you want data to be sent continously. (at least this is the syntax if you are using java)
mySocket.setTcpNoDelay(true);
This option solved my latency issues when I sent real-time coordinates over a network.
Edit: I think TCP by default waits and bunches together data before sending it, which could be a problem if you want to send small updates fast.