0

I need to connect Unity3D client to Photon Server using both UDP and TCP connections. Is it possible? Where can I read about it? P.S. I want to use TCP to send large amount of data.

Art Drozdov
  • 157
  • 1
  • 11

3 Answers3

0

Simple answer: No. A photon server cannot have more than 1 type of connection. However, there is a way to do this depending on your definition of a 'server.' For the basis of this explanation, lets call a server the object instance running on a machine. The machine the server is running on, we'll call the machine. You can have multiple servers running from a single machine where they can have different types of connections. For instance, you could have the unity client connect to the physics server using a UDP connection and connect the client to whatever else you needed using a TCP connection.

Joey Quinto
  • 367
  • 2
  • 6
  • Should I implement separate ApplicationBase descendant to handle TCP connections? – Art Drozdov Dec 02 '14 at 12:41
  • It really depends on your preference, but I would recommend it. I have an abstract class called PhotonApplication that inherits from ApplicationBase and I use that abstract class to create all my main server classes. – Joey Quinto Dec 02 '14 at 21:01
  • Photon Server does support mutiple connection types - see answer below. – archgl Jan 13 '15 at 11:59
  • @archgl: you should never reference to an answer via "below" or "above" on Stackoverflow, as, like you can see, the order of answers can change over time! – Kaiserludi Jan 21 '15 at 16:14
0

Photon server supports multiple protocols simultaneusly. If you downloaded the server sdk look for the PhotonServer.config:

It contains entries like this

<UDPListeners>
    <UDPListener
        IPAddress="0.0.0.0"
        Port="5055">
    </UDPListener>
</UDPListeners>

and

<TCPListeners>
    <TCPListener
        IPAddress="0.0.0.0"
        Port="4530"
        PolicyFile="Policy\assets\socket-policy.xml"
        InactivityTimeout="10000"
        >
    </TCPListener>
</TCPListeners>

Your clients can connect per udp or tcp and interact with each other no mater what protocol thy have chosen.

For the full set of configuration options you can look here: http://doc.exitgames.com/en/onpremise/current/reference/server-config-settings

When a client connects you can query in your server side application how the client connected like this:

public class YourApplication : ApplicationBase
{

    if (initRequest.LocalPort == 5055)
    {
    //
    }

    if (initRequest.PhotonPeer.GetListenerType() == ListenerType.TCPListener)
    {
    //
}

Note: UDPListener in the config are represented as ListenerType.ENetListener in code.

You can find the server sdk documentation in the downloaded {sdk}\doc\Photon.SocketServer.chm or online here http://doc-api.exitgames.com/en/onpremise/current/server/doc/annotated.html

archgl
  • 2,632
  • 1
  • 16
  • 10
0

Photon server handle connect object called Peerbase. Each peer is each client connection. In client peer connection you only choose protocol is UDP or TCP. Solution is create two peers, one is UDP and one is TCP but hard to handle what UDP and TCP peer is in one client to find player info and send data

Pham Lai
  • 151
  • 1
  • 7