We are working on a multiplayer game in Unity. The players can have weapons. The weapons and their attributes are stored in the database on the server database. But how can we show all the weapons in the game(not only player owns) to the player. Do we need to make a database on the client side too? (mobile game so we don't prefer database) or send all the information to the client when he logs in the game?
I was thinking of storing the information in a XML file on the client side and initialize the weapons with a script, but on the other hand the players can reach this file and change it. (not a security issue but we don't want them to do this). Can you tell me some other approaches?
Basically it depends on the way you use the weapons in your game. I suppose that your server must be synchronized with the client version and the weapons your client can handle in game logic, otherwise when your character will get a new brand weapon he can't handle by the game logic you will not accomplish anything.
On the other hand, if you have generic weapons (gun with fire rate +1) with game logic that can handle the fire rate change, there will be no problem adding gun with fire rate +3 on the server side without updating the client.
So if we are talking about the first case, no need to update the client unless you want to display a list of new weapons available for the client in the next version. For the second case you can synchronize the weapon list on user login.
Related
we want to build an application (c#/.Net) for the following Scenario:
internal "alert System". Users should be informed about it-system outage, planned downtime for Services and so on.
only one-way : central Service will push Messages to user
we also Need the possibility to enable/disable a message, for example:
The message "there a Problems with mail System" should be removed from every Computer after the Problem is solved
we want to shedule Messages for planned maintanance
about 1000 windows Clients, we also want to "group" this Clients, so we can control which Client will get a message
First thought was writing small application which will query every X seconds a central database for new and existing Messages.
Maybe somebody has already worked on similar Project?
Is a Client with database query a way to go? Better to use other Technology, like WCF Service?
Thanks for your help
Marc
Sounds like you need an enhanced version of push notifications.
I'd suggest using push for all the messaging, it's delivered faster and I find it more reliable. Simply make the client connect to a message server and maintain the connection open. Whenever a message is supposed to be displayed to the client, have the server push it trough the connection (that's where the name comes from).
To group and manage the clients you could use a database, it's probably the best way to go, but the server needs to handle all the open connections, and databases can only store DATA, not virtual objects representing a connection, so the server software need to manage them in a different way.
My suggestion: Whenever the server receives an incoming client connection, it will accept and query the client computer for a ID number that will also be used to find that client's information in the database.
Then it will create a dictionary using that ID as key, and the connection as the value.
This way at the time of sending a message to a determined group, you can do in two ways:
1) You can load from the database the IDs that belong to that group, and then send the messages to them. You will have to check whether that ID exists in the dictionary's KEYS array, because it is possible that a determined client is not yet connected.
2) You can iterate of the KEYS array of dictionary, check to which group that ID is part of, and if it is the desires group, send it.
If you're dealing with a big number of clients, I suggest you use method 1.
To disable/remove a message from the client's computer, simply have the server send a special Command message that the client software interprets as "remove that message". To make this possible every non-command message must have unique IDs, so that command messages can tell the client software which message that command applies to.
Your project sounds very interesting.
I would be glad to help you by writing a library you could use, or just help you figure it out on your own if you prefer. (Free of charge, just for the experience).
We don’t have wi-fi in every area of our outdoor facilities. So, we have the need for users to work with data sets disconnected and then sync back up. Our thought is to have the user’s PC poll for wi-fi every 60 seconds. If it sees it, it connects and uploads/downloads data.
So let’s say a user’s PC grabs a data set and goes off and works locally with it (inserts/updates/deletes). Meanwhile, someone else is inserting/updating/deleting the same data set directly in the database (someone back in the office). How then, can we rectify everything?
E.g. if record “1” has a value of “blue” and the user downloads it locally. It then changes “blue” to “red” while offline. Once wi-fi is found, it could just update, but if an office user had changed “blue” to “green” it might be a bad thing. “Last one wins” I suppose could get us in trouble.. especially if the offline user inserts a record not realizing that the office user has as well.
This question really isn't how to do something technically. I suppose it's more about looking for a best practice.
Thanks for any feedback.
You dont have to reinvent the wheel, there is already a tools to synchronize database e.g symmetricds to facilitate data synchronize for inserts/updates/deletes operations.
I'm trying to figure out how I could send information and arrange a simple database on my home computer. I'd want to send the information through my phone while I'm away from home. The information is simple it's to keep track of how much money I spend so I would need to send an amount spent, the date (wouldn't matter as much), and the reason it was spent, then store that somewhere and be read when I get home. Any ideas?
You need to port forward your home router on some port (i.e 80 or 8080). Then you can code a small server program or simply host a HTTP server with some script language extension (i.e PHP) to communicate with your database. Your program can define different service calls to manage different tasks (i.e inserting, deleting, updating entries). Using a minimalist REST framework would reduce time being spent on coding.
Edit:
You phone can use these service calls to manipulate your db via its browser or some client program you write.
I would like to implement a chat system as part of a game I am developing on App Engine. To implement this, I would like to use WebSockets, and have clients connect to each other though a hub, in this case an instance of GCE. Assuming this game needed to scale to multiple instances on GCE, how would this work? If I had a client 1, and the load balancer directed that request of client 1 to instance A, and another client (2) came in and was directed to instance B, but those clients wanted to chat with each other, they would each be connected to different hubs, and would be unable to reach each other. How would this be set up to work with scale? Would I implement it using queues, where each instance listens on that queue, and if so, how would I do that?
Google Play Game Services offers exactly the functionality that you want but in regard to Android and ios clients. So this option may not be compatible with your game tech design.
In general you're reasoning correctly. Messages from client who want to talk to each other will most of the time hit different server instances. What you want to do is to make instances handle the communication between users. Pub/sub (publish-subscribe pattern) is very suitable pattern in this scenario. Roughly:
whenever there's a message directed to client X a message is published on the channel X,
whenever client X creates a session, instance handling it subscribes to channel X.
You can use one of many existing solutions for starters. It's very easy to set this up using redis. If you need something more low-level and more flexible check out zeromq.
You can expect single instance of either solution to be able to handle thousands of QPS.
Unfortunately I don't have any experience with scaling neither of these solutions so can't offer you any practical advice as to the limits of their scalability.
PS. There are also other topics you may want to explore such as: message persistence and failure recovery I didn't address here at all.
I didn't try to implement this yet but I'll probably have to soon, I think it should be fairly simple to handle it yourself.
You have: server 1 with list of clients and you have server 2 with another list of clients,
so if client wants to send data to another client which might be on server 2, you have to:
Lookup if the receiver is on current server - if it is, you just send it (standard)
Otherwise you send the same data to all other servers you have, so they would check their lists for particular client (or clients) and send data to them.
I am currently developing a real-time multiplayer game, and have been evaluating various cloud-based hosting solutions. I am unsure whether App Engine fits my needs, and would be grateful for any feedback.
In essence, I want the system to work like this: Player A calculates round n, and generates a hash out of the game state at the end of that round. He then sends his commands for that round, and the hash, as a http POST to the server. Player B does the same thing, in parallel.
The server, while handling the POST from a player, first writes the received hash code to the memcache. If the hash from the other player is not yet in the memcache, it waits and periodically checks the memcache for the other players hash. As soon as both hashes are in the memcache, it compares them for equality. If they are equal, the server sends the commands of each player to the respectively other one as the http response.
A round like that should last around half a second, meaning two requests per player per second.
Of course, this way of doing it will only work if there are at least two instances of the application running, as two requests must be dealt with in parallel. Also, the memory cache must be consistent over all instances, be fairly reliable, and update immediately.
I cannot use XMPP because I want my game to be able to run within restricted networks, so it has to be limited to http on port 80.
Is there a way to enforce that two instances of the app are always running? Are there glaringly obvious flaws in my design? Do you think an architecture like this might work on App Engine? If not, what cloud based solution would you suggest?
I believe this could work. The key API for you to learn about / test would probably be the Channel API. That is what would allow back and forth communication between the client and server.
The next issue to worry about would be memcache. In general, it is reliable, but in the strictest sense we are supposed to assume that memcached data could disappear at any time.
If you decide that you can't risk losing the data like that, then you need to persist it in the datastore, which means you will have to experiment to make sure you can sustain 2 moves per turn. I think this is possible, but not trivially so. If you had said 1 move every 3 seconds I would say "no problem." But multiple updates to one entity per second start to bump up against the practical limit on writes per second, especially if they are transactional.
Having multiple instances running will not be a problem - you can pay to keep instances warm if necessary.