Client-Server-Clients* gaming system - c#

I am building a multiplayer game in Unity. For that purpose, I have to send some values from client to two or more clients who are connected via a Server.
I want to build it as a server authentic game. Clients will be using Android and their data will be synchronised via a Server (may be some PHP functions or else, I don't know very well).
I can send data to my server from game but How can I send that data to other clients via my Server?
Actually I don't want to sync all players scene (i.e. gameObjects positions which can be done using the Unity's built-in networking or Photon ) because I want to show them different views and This is why I have to make communications among clients via my own Server.
Can anyone please help me out? Any help link or tool name or any kind of tutorial link is highly appreciated.

You need to use WebSocket protocol. It can open bidirectional connection for you so you can push message to your client when you need.
WebSocket protocol in Wikipedia
Unity3d open source websocket plugin

I am successful in doing what I needed. I am using Photon. Using RPC's I am just sending information to clients and In clients, I parsed the information and used it to show them in the game scene. No gameObjects are spawned in Network.
One user creates room, and other joins that room.
Just using RPC's i am syncing the informations.
Thank you all for helping me.

Related

How do you make a C# server that can store its connection to clients AND update them when needed

I'm trying to make a simple multiplayer turn based game. I have little experience with c# servers so I am trying to learn. It would need to be able to play something like chess over the internet.
My Goal: to have a server that can accept messages from clients (like join game, do a move, etc) and be able to store the Client's connection when they join and then update them on information in the game at any time, like when a opponent moves or something. (I would want to be able to expand it to more than two players)
My Problem: everything I can find about c# servers are sockets. The problem with sockets as far as I can tell is that they are one-way connections, meaning a client can only get data once after they send data. I would want to be able to update them multiple times after that, showing in close to realtime what happened in the game world after their turn is over.
How would I achieve this? Would I need clients to have listeners too? How do I store a connection when a new socket is created every time that a new request is made?
Thank you for any help/knowledge you can give!
I am not sure what sockets do you mean but WebSocket is a technology which, in a few words, enriches HTTP with full duplex communication between client and server. If we are talking about C# look at SignalR which can use WebSocket.

Realtime WebApp: Send the same data for all connected clients at the same time

I want to create simple game which data will be send to clients by the server. Clients should have the same data at the same time, data should be generated by the server. If the server returns some rand() value it could be the same for all. It could generate data via interval 24/h every 1minute new value.
Clients excercise is to guess the value which server return, on succes this player win, and new rand starts.
What technology i should to use, it could be web app availible on browsers. I prefer to create it with c# and websockets, but i dont know how to integrate data for all clients.
Help, thanks.
Luckily Node provides socket.io library which you can use to achieve this level of functionality.
Get Socket.io Details
With socket.io you can broadcast the same data to all connected users using websockets.

How does multi player communication work from a client to a poker server?

I just started to work with client-server communication and I created a poker game that works on Android and iPhone and connects with a C# server. Right now I'm using PubNub to send and receive messages but there are either one of two problems with this:
I need to poll the sever and get the table status all the time so there will be a lot of messages which means that the server needs to send more messages (more overload) and a higher cost (as PubNub pays per message)
(or)
The table will not always be 100% updated on the client (Android/iPhone)
So my question is how do bigger poker sites like PokerStars handle the communication? Do they set up sockets and send the information all the time to the connected users to that connected table?
Any information about creating this kind of communication between one server and several mobile devices (and also Windows C# clients) would be highly appreciated.
I cannot give you an answer to your question but my approach would be using a tool like WireShark and try to find it out by analyzing the (amount of) packets that are exchanged.

Sending a data from android phone to pc?

I am creating a "tracking system" for my android phone. Basically, the phone would transmit it latitude/longitude to a C# program that will receive the coordinates and display it on a map. I managed to get the phone's latitude/longitude coordinates but I need a way to transmit that data to my C# application running in my PC. I know my way around C# and Java but never really got into network programming. Is there a way to do this ?
I'd look into C# Webservices, very powerful. The communication protocol is SOAP (Simple Object Access Protocol) which is a popular and well supported standard.
Good starting reference: Your first C# Web Service
I can't speak to the C# side of it, but if you write a C# server to receive post requests, the Apache HttpClient makes it relatively simple to send requests. There are a bunch of other questions on SO that will help with setting up the client side on your phone if you poke around a bit.
You have different way to do it.
The first is to send data over the cloud to interact through distant server. So the both devices have to be connected to Internet
The second id to send the data over a local network so the data have to be on the same network and have to share their IPs
The third is to use adb forward which allows to build a socket connection between the 2 devices over a USB cable. The requirements are that the phone have to be on debug mode I think and that the driver are installed on the PC so the phone is recognized by ADB.
I can add one more by using a Bluetooth connection. Find information here
The correct way to do it would be to build WCF service which allows many different protocols to receive data. This would could be a very powerful solution that can be extended in future.
The fastest and easiest IMO would be to create ASP.NET MVC application, define a POCO Model for your longitude/latitude and create an action that would take your Model as parameter. Then use HttpClient and HttpPost on android to send the data. The trick here is to name the variables in your post request same as ones you define in your C# Model.

XMPP C# Interaction

I am trying to connect via c# and via javascript to an xmpp server (currently ejabberd). Im having a little trouble conceptualizing how the connections will exists.
Backstory: I have a game engine that will take input from the user and send some kind of response back to them. The user may be a windows app, a web app, all needing to connect pretty much the same way. The game engine is a c# application that handles the input accordingly. Is my game engine a user on the xmpp server just like everyone else? How does he talk to the others and vica verca. A detailed tutorial on how this kind of thing is done using xmpp is greatly appreciated if possible.
Are there c# libraries to handle the xmpp connection in the way I specified above? Would the javascript also be hitting the xmpp server in the same way?
Your game server would be an XMPP component which your users could directly communicate with, like they can with any other user, server or component in an XMPP system.
Users log into your server (say example.com) in the standard way, then they can start sending messages of whatever type you like directly to your component (game-engine.example.com). Your game engine component exists separately to your XMPP server and the two communicate using the Jabber Component Protocol. Your client can also send directed presence to the component if you want it to be able to initiate communications.
Though, as you're using ejabberd, you could also implement the game engine messaging system as an ejabberd module.
This probably answers your question about a C# XMPP library: https://stackoverflow.com/questions/1166252/net-xmpp-libraries-under-apache-mit-or-ms-pl-licenses

Categories