How to Identify Sever and Client Seprately in Unity 3d - unity3d

I am trying to understand data synchronization in Unity network development.
First Problem that I am facing is to understand unity3D server client model.
1
My basic understand is that one machine behaves as server + client and other simply client.
But in following graphics when hosted from PC build there is no server at all????
When I host it from Unity Editor now there are both server + Client.. why???
2
The other problem I am trying to solve that is to make such a behavior in which if I press space button at server it increments the server score.
Same goes to client when space is pressed at client it increment the client score.
No progress at all because I am unable to figure it out how to separate the server date from client data. Trying to get the reference of two different Text objects if it is server it gets the server text from hierarchy and if it is client make it to get the client text object from hierarchy.
I hope Graphics are self self explanatory.

When you host from standalone builds you can't see who's the host directly in inspector on client. You can create UI to display information about network identity and make sure everything is correct.

for the first question, remember:
When you Join game as a Host You are Server + Client
When you Join game as a Server you are only server.
When you join game as a Client you are only client
You check these thing in build and develop your OWN GUI to view the checks as you mentioned.
Yes you can differentiate client and server using these checks
if(isLocalPlayer){
//yes this is the local player
//The class must be derive from networkBehaviour to access this property
}
and You can also use Network class to check is Server.

Related

Simple Localhost Server in Xcode/Swift?

I am making a macos app in XCode, and I was wondering if there was a way to make it host a local server that is visible across the network.
I am trying to find a way so that it would host something on the devices's network with it's hostname/ip address, so if someone goes to http://hostname:5000 they would be able to see the response, and the app would be able to see the request, just like how hosting a local python server works. Is there any way to do this in XCode with Swift?
For example: the user presses 'start server' on their screen. The server is hosted across the network. Anytime a request is made to it, they get a notification.
Just to make you concern you may find some sample codes, including local web server inside the app.Few of them I found are:
https://github.com/ooper-shlab/MyWebViewApp-Swift
https://github.com/depoon/SwiftLocalhost
The main thing is it's just a public
, experimental code, so it's not simple, not easy to adopt, not all coding best-recommended, far from readable and may have severe bugs.But you can use it as a working example and take any parts of it into your app.

networkView ViewID RPC in UNITY

I'm new to unity, I thought it was going to be a piece of cake, but now I'm thinking I bit off more than I can chew.
I'm trying to make an authoritative server game, where the client players send their desired movements to the server, then the server sends back to all clients, the actual movement position information.
When a client connects to the server, the server uses RPC calls to create the player objects on all of the clients. In the player script Awake() function, I create a NetworkView object, and attach it to the player object dynamically for synchronization. So all player clients are doing this as each new player connects to the game server, so everybody can see everybody else.
The problem I have is when the player client wants to move, the client tries to do RPC call to the server using the dynamically attached NetworkView, to send the desired movements, but the RPC call fails, giving an error on the SERVER (not the client), that the server cant find the NetworkViewID.
My code didn't print this error, so I guess it must be code deep inside unity that printed it when it received the RPC message from a client, and tried to match it up with a corresponding NetworkViewID on the server, when it could not, it printed the error?
I'm just wondering how unity works.... does object "A" on all clients and server have the same NetworkViewID, and object "B" on all clients and servers have the same ID (but different ID from "A")?
If so, how do NetworkView objects that are instantiated on clients and server know which ID to assign themselves so they all match up when this is being done on different computers over the network? Is this done automatically by unity, or do I have to send the ID myself to all NetworkView objects?? But I cant talk to the objects to tell them which ID to use, since I dont know the NetworkID in the first place, since that is apparently needed to talk to the NetworkView objects! Its like trying to ask someone their name, but you need their name in order to ask them. So that cant be how it works.
My problem is that at first, the player object has no NetworkView on it. After the object is created, the script on player object dynamically attaches a NetworkView. Since this is done on all clients, and on the server almost at the same time, how will they all know to assign the same ID to the same objects, so that they can RPC each other?
Also I read somewhere that the "owner ID" is always zero?
Sorry I'm new to unity, and trying to figure it all out. Can anyone give me the inside scoop on all this?

How do I connect this chat program to two computers?

So I have been modifying the chat program found here: http://www.dreamincode.net/forums/topic/259777-a-simple-chat-program-with-clientserver-gui-optional/ and I am at the point where I am ready to use it between twp pc's.
The problem is, I do not know enough about server-client relationships to set it up. Is there anything missing in the code for this to work? I just want to link two laptops to chat with one another. Is there any server softare I need to run or something?
I tried openfire but couldn't figure out how to link it, every port number I tried (listed in the admin page) didn't work. This is my first attempt at anything like this and probably beyond my current level of understanding which is why I would greatly appreciate a straightforward solution.
I chose this becaue I needed to do a lot of customization to the code so please use the ones on the page above as a reference. I would post the code here but there are 5 classes and they are neatly displayed on that page already with a explanation of each.
Thanks in advance!
Before you start trying to incorporate external libraries or functions, understand the code. Play around with it a little. See what does what and if you change this setting or that what will happen. Bare in mind that the code is separated into 2 applications:
Client - [ClientUI + Client + ChatMessage]
Server - [ServerUI + Server + ChatMessage]
Check that the application works on a single machine. So keep the server class the same and simply edit the client class so that it points to the current machine.
Run both the server and the client (from the example) on the same machine and when the client asks for the server location input 127.0.0.1 then put the port number you gave for the ServerSocket in Server. This should point to your machine and if this works but not when using 2 separate machines check your firewall settings.

How to connect and pull data out of funambol dm server using j2se client ?I

I have installed the DM server and it is up and running.Also added couple of device details via koneki simulator.
Now i want to use one of the j2se client to connect and pull data from DM server.
I am struck on this part.Any code sample ?
Actually, there is an OMA-DM client underneath the Koneki simulator that you might want to reuse!
You can grab the source code from the GitHub mirrors of the OMA-DM simulator: here and here
org.eclipse.koneki.simulators.omadm is used to run a new OMA-DM session. Look for the run() method in the class org.eclipse.koneki.simulators.omadm.basic.DMBasicSimulation
org.eclipse.koneki.protocols.omadm defines the object model used during a simulation.
org.eclipse.koneki.protocols.omadm.client (the most interesting for you) manages all the messages that are exchanged between a client (e.g. the simulator) and a server. Look for the org.eclipse.koneki.protocols.omadm.client.basic.DMBasicSession class.
You should stop by the Koneki forum if you have any further questions (and I am sure you will!)

GWT - How to detect if we are on the same machine as the server

I`m currently developing a gwt application on a embedded device (linux with touchscreen) the server and client is started on the device.
I want my client to detect if it`s on the device or not. Because some screen are not available when connecting remotely
You can make a call to the server first and check there if it was made from remote or local address. A response from server should indicate if show screen "A" or not. Hope this helps.
Deferred binding might be the answer. GWT MobileWebApp sample app uses it to discern the form factor of the target in FormFactor.gwt.xml. In essence you define a property and write a provider which determines its value. You then read the property and deliver the appropriate View (in the MVP sense).
BTW I am developing an app for a similar scenario and I'm thinking of reimplementing my solution: reading a URL query parameter which is only present in the browser on the embedded device. Not too awesome. The aforementioned example should allow better hiding of the embedded platform identifier.