Phoni Terms

From ETC Public Wiki
Jump to: navigation, search

Phoni System

This page is associated with Phoni System, a network framework to make standalone device into game controllers for PC. Please visit Phoni System for other information.

Phoni Terms


  • NetworkInfo
    The class contains IP address and port information, acting as an identifier for your player/game on network.
  • PhoniDataPort
    As we mentioned in section Get Started with Phoni, in terms of data, we treat game and player identically as the form of PhoniDataPort. PhoniDataPort is a representative of your local device to communicate with a representative with connected remote device (aka another PhoniDataPort).
    If you are a game device, you may have multiple PhoniDataPort to talk to multiple remote player device, where each of these PhoniDataPort is a "player" in PhoniInput.Player. Similarly if you are a player device, your PhoniDataPort is a "game" in PhoniInput.Game. There might be a situation that your device host a game and also act as player for another device. In this case you will make use of both PhoniInput.Player and PhoniInput.Game to retrieve data from connected players and provide data to connected game. More info for this situation please refer to section Advanced Use of Phoni -> Game and Player on the same device.
    PhoniDataPort has most everything you need to deal with remote device: send/retrieve data, send command and check status. The (kind of) exception is receive command. In this case we call your command process callback just to make the things easier; but still a PhoniDataPort will be passed in to let you know which player or game (determined by IsPlayer/IsGame property) sent the command.
    The figure shows a network model for PhoniDataPort.
    There are two important network identifier for PhoniDataPort:
    Since the IP address will always be the IP of your device, local network info is really about which port your representative(PhoniDataPort) is using to talk to remote device. If you are in game side and your representatives are connected to Players, they share the same port as the port you open up to start the game. If you are in player side and your representatives are connected to Games, they will not have the same port, and their port is assigned by system when you connect to the game.
    Your representative's remote network info is the local network info of the representative of the remote device that talks to you, which contains the remote device's IP address and communication port for you. For example, if device A and B is connected and their representative for each other is called phoniDataPortAtoB and phoniDataPortBtoA respectively, we simply have phoniDataPortAtoB.RemoteNetworkInfo == phoniDataPortBtoA.LocalNetworkInfo and phoniDataPortBtoA.RemoteNetworkInfo == phoniDataPortAtoB.LocalNetworkInfo.
    The figure shows a visualized relation of these two identifiers, where the same color indicates the same value.
  • PhoniClient
    Basically you don't need to go deep into this. PhoniClient is the underlying network client for each PhoniDataPort. It contains UDP client (read thread and write thread) and TCP client (read thread), and it helps coordinate all data I/O via network.
  • PhoniDataBook
    When you access PhoniInput.Player or PhoniInput.Game, you are actually accessing PhoniDataBook; and these are the only two PhoniDataBooks in the Phoni System. PhoniDataBook is a collection of PhoniDataPort and provide operations as Connect & Add (handled internally), Remove & Disconnect, Check existence and Access PhoniDataPort.
  • PhoniDataWrapper
    When you access data for PhoniDataPort as phoniDataPort.TouchData, you are actually accessing PhoniDataWrapper. PhoniDataWrapper(a series of generic classes) is used to wrap up your data to make it ready for sending/receiving via UDP, it also handles data synchronization between threads. As a game, you access phoniDataWrapper.ReceivedData to retrieve data sent to you, and as a player you modify phoniDataWrapper.SendingData to prepare for sending. phoniDataWrapper.IsValid indicates whether the ReceivedData is valid. The data is valid if the wrapper received it from a remote source at least once, so the value is not its initial value.
  • PhoniData
    PhoniData(a series of generic classes) is the underlying data format for PhoniDataWrapper, it is also used for the data sending/receiving with command via TCP. PhoniData handles data serialization and deserilization in multiple cases.
  • PhoniCommandInfo
    PhoniCommandInfo is a passed-in parameter for your command process callback. It contains a PhoniCommandCode and a PhoniDataBase, which is the base class of PhoniData.
  • PhoniCommandCode
    An enum for all available commands in the system. Add in a new code here if you want to have a custom command.
  • PhoniDataCode
    An enum for all available data declared in PhoniDataPort. Add in a new code here if you want to have a custom data, and declare your data in PhoniDataPort with this new code. See Advanced Use of Phoni -> Create Custom Data for more details.
  • PhoniPackageCode
    An enum for all available package types used in network transaction, associated with different types of PhoniData. You don't need to handle this part unless you want to create your own PhoniData. See Advanced Use of Phoni -> Create Custom Data for more details.


If you have any question or if you are interested in further development, please contact [Xun Zhang].