EzDev.org

photon

photon - The fastest way to build beautiful Electron apps using simple HTML and CSS Photon photon: build desktop apps with simple html and css components.


Unity Photon room.SetCustomProperties Not Working

According to what I looked up online, most of the examples take in one parameter which is a single Hashtable. However, I kept getting an error saying there is no overload method that takes only one argument. It requires three. This is the example I came up with but I still get an error saying it has invalid arguments.

How do I use room.SetCustomProperties?

public void PlacingStone ()
{
    Hashtable setPlacingStone = new Hashtable {{ RoomProperties.PlacingStone, true }};
    Hashtable currentValues = new Hashtable {{ RoomProperties.PlacingStone,
    (bool) PhotonNetwork.room.customProperties [ RoomProperties.PlacingStone ] }};
    PhotonNetwork.room.SetCustomProperties ( setPlacingStone, currentValues, true );

    StartCoroutine ( "WaitOnStone" );
}

Source: (StackOverflow)

How to fix multiplayer stuttering?

For some reason the other player's movement is 'stuttering'. I know this is a common problem people run into with Photon, so was wondering if anyone knows how I can resolve it?

Here's my player movement code:

public float SmoothingDelay = 5;

public void Start() 
{
    GetComponent<SmoothSyncMovement>().enabled = true; //This is the name of this script
}

public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
{
    if (stream.isWriting)
    {
        //We own this player: send the others our data
        stream.SendNext(rb2D.position);
        stream.SendNext(rb2D.rotation); 
    }
    else
    {
        //Network player, receive data
        correctPlayerPos = (Vector3)stream.ReceiveNext();

    }
}

public void Update()
{
    if (!photonView.isMine)
    {
        Vector2 playerMovement = rb2D.position + velocity * Time.deltaTime;
        rb2D.MovePosition(playerMovement);          
    }

    if (photonView.isMine)
    {
        Vector2 playerMovement = rb2D.position + velocity * Time.deltaTime;      
        rb2D.MovePosition(playerMovement);
    }
}

Source: (StackOverflow)

Cannot get PubNub EON chart to work

I have run into a dead end trying to get the following HTML to work. I am trying to use the real time gauge chart to display a value coming from a photon. This is the snippet code from the pubnub site.

(I have proven that the published value is arriving in the Javascript using the commented out pubnub code in the Javascript. The value is displayed in the P tag.)

The P tag is displayed on the screen, but no gauge is displayed.

Could you please have a look at my code and guide me on where I have made a mistake. I have not worked with EON before, so I may be making very basic mistake.

<!DOCTYPE html>

<html>

<!-- <script type="text/javascript" src="http://cdn.pubnub.com/pubnub-3.16.1.min.js"></script>  -->

<script type="text/javascript" src="//pubnub.github.io/eon/v/eon/0.0.10/eon.js"></script>
<link type="text/css" rel="stylesheet" rel='nofollow' href="//pubnub.github.io/eon/v/eon/0.0.10/eon.css"/>


<div id="chart"></div>
<script type="text/javascript">
*var pubnub = PUBNUB.init({subscribe_key:  'xxxxxxx'});

/*
  pubnub.subscribe ({channel : "datatest", message : function(tempmsg)
            {document.getElementById("x").innerHTML = tempmsg.eon.data;}});

*/

var channel 'datatest';
eon.chart({
            channel: channel,
            generate: {
                        bindto: '#chart',
                        data: {
                                type: 'gauge',
                                },
                        gauge: {
                                min: 0,
                                max: 100
                                },
                        color: {
                                pattern: ['#FF0000', '#F6C600', '#60B044'],
                                threshold: {
                                                values: [30, 60, 90]
                                            }
                                }
                        }
            });
</script>



<body>
    <p id ="x"> This is my text that will be replaced by the value from the photon </p>
</body>

</html>

The output from the photon looks like this:

publishing message: {"eon": {"data":56}}
publishing message: {"eon": {"data":56}}
publishing message: {"eon": {"data":56}}
publishing message: {"eon": {"data":56}}

Source: (StackOverflow)

Akka.NET + Photon Server

Is it possible to use Akka.NET with Photon Server?

Can't find any info about this.

How scalable this solution? Found some articles about Akka + Scala game servers, but nothing about Photon + Akka compatibility.


Source: (StackOverflow)

AWS SDK S3 ListObjectsV2 gives NullReferenceException in Photon Server

I'm running AWS SDK from Photon Server application and trying to query the contents of S3 bucket using the AmazonS3Client.ListObjectsV2() method based on the example from AWS site. Using the same code in another application works just fine, but in the Photon Server application it outputs the following error message to Photon logs

2016-10-12 15:19:52,614 [11] ERROR Photon.SocketServer.ApplicationBase [(null)] - System.NullReferenceException: Object reference not set to an instance of an object.
at System.Security.Permissions.FileIOPermission.CheckIllegalCharacters(String[] str, Boolean onlyCheckExtras)
at System.Security.Permissions.FileIOPermission.AddPathList(FileIOPermissionAccess access, AccessControlActions control, String[] pathListOrig, Boolean checkForDuplicates, Boolean needFullPath, Boolean copyPathList)
at System.Security.Permissions.FileIOPermission..ctor(FileIOPermissionAccess access, String path)
at System.Configuration.UriSectionReader.GetSectionData()
at System.Configuration.UriSectionInternal.LoadUsingCustomParser(String appConfigFilePath)
at System.Configuration.UriSectionInternal.GetSection()
at System.Uri.InitializeUriConfig()
at System.Uri.InitializeUri(ParsingError err, UriKind uriKind, UriFormatException& e)
at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind)
at Amazon.Runtime.AmazonServiceClient.ComposeUrl(IRequest iRequest)
at Amazon.Runtime.Internal.HttpHandler`1.CreateWebRequest(IRequestContext requestContext)
at Amazon.Runtime.Internal.HttpHandler`1.InvokeSync(IExecutionContext executionContext)
at Amazon.Runtime.Internal.RedirectHandler.InvokeSync(IExecutionContext executionContext)
at Amazon.Runtime.Internal.Unmarshaller.InvokeSync(IExecutionContext executionContext)
at Amazon.S3.Internal.AmazonS3ResponseHandler.InvokeSync(IExecutionContext executionContext)
at Amazon.Runtime.Internal.ErrorHandler.InvokeSync(IExecutionContext executionContext)
at Amazon.Runtime.Internal.CallbackHandler.InvokeSync(IExecutionContext executionContext)
at Amazon.Runtime.Internal.RetryHandler.InvokeSync(IExecutionContext executionContext)
at Amazon.Runtime.Internal.CallbackHandler.InvokeSync(IExecutionContext executionContext)
at Amazon.Runtime.Internal.CallbackHandler.InvokeSync(IExecutionContext executionContext)
at Amazon.S3.Internal.AmazonS3ExceptionHandler.InvokeSync(IExecutionContext executionContext)
at Amazon.Runtime.Internal.ErrorCallbackHandler.InvokeSync(IExecutionContext executionContext)
at Amazon.Runtime.Internal.MetricsHandler.InvokeSync(IExecutionContext executionContext)
at Amazon.Runtime.Internal.RuntimePipeline.InvokeSync(IExecutionContext executionContext)
at Amazon.Runtime.AmazonServiceClient.Invoke[TRequest,TResponse](TRequest request, IMarshaller`2 marshaller, ResponseUnmarshaller unmarshaller)
at Amazon.S3.AmazonS3Client.ListObjectsV2(ListObjectsV2Request request)
at AWSConnector.AWSConnector.ListSubfolders(String prefix)
at InstanceManager.Handlers.InstanceManagerUpdateInstancesHandler.OnHandleMessage(IMessage message, PhotonServerPeer serverPeer)
at Boson.Photon.Server.PhotonServerHandlerList.HandleMessage(IMessage message, PhotonServerPeer peer)
at Boson.Photon.Server.PhotonServerPeer.OnOperationRequest(OperationRequest operationRequest, SendParameters sendParameters)
at Photon.SocketServer.ServerToServer.ServerPeerBase.OnReceiveInternal(Byte[] data, SendParameters sendParameters, Int32 rtt, Int32 rttVariance, Int32 numFailures)
at Photon.SocketServer.PeerBase.<>c__DisplayClass6.<Photon.SocketServer.IManagedPeer.Application_OnReceive>b__5()
at ExitGames.Concurrency.Core.DefaultExecutor.Execute(Action toExecute)
at ExitGames.Concurrency.Core.DefaultExecutor.Execute(List`1 toExecute)
at ExitGames.Concurrency.Fibers.PoolFiber.Flush(Object )
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
at System.Threading.ThreadPoolWorkQueue.Dispatch()

I'm afraid this might have something to do with the way threading is handled in Photon.


Source: (StackOverflow)

Unity3d WEB GL build with photon network

I has been developed multiplayer unity3d shooter with photon network(PUN). It builded fine and running for windows(exe), but it does not work in browser(web gl).

Test project without photon works fine in browser. I think the problem linked with photon. There are several exceptions in js console.

Build is hosted on

google drive. Could You please explain the reason of this problem?

Unity3d 5.3.1. Photon Unity Networking v1.65. Build was tested with chromium, firefox and internet explorer. Windows 7 x64.


Source: (StackOverflow)

Do I have to change anything in the source code when I upgrade to a higher CCU in photon?

We have a project in Unity3d and it uses 20 CCU. We wanted to upgrade to a higher CCU in photon, do we have to change anything in it's source code or if we buy an upgrade in Photon we can leave the source code as it is? Thank you


Source: (StackOverflow)

Sending data using Hashtable on Photon Cloud

I am trying to send data using Hashtable on photon cloud, I do receive the data with correct eventCode, but the key-value pair returns some random numbers. My code is like this while sending data:-

void NetworkLogic::sendEvent(void)
{
    ExitGames::Common::Hashtable* table =new ExitGames::Common::Hashtable;
        table->put<int,int>(4,21);
        const ExitGames::Common::Hashtable temp = (const ExitGames::Common::Hashtable)*table;//= new ExitGames::Common::Hashtable;
        mLoadBalancingClient.opRaiseEvent(false, temp, 100);
}

While receiving data, the code is like this:-

void NetworkLogic::customEventAction(int playerNr, nByte eventCode, const ExitGames::Common::Hashtable& eventContent)
{
    // you do not receive your own events, unless you specify yourself as one of the receivers explicitly, so you must start 2 clients, to receive the events, which you have sent, as sendEvent() uses the default receivers of opRaiseEvent() (all players in same room like the sender, except the sender itself)
    PhotonPeer_sendDebugOutput(&mLoadBalancingClient, DEBUG_LEVEL_ALL, L"");
    cout<<((int)(eventContent.getValue(4)));
}

What I get printed on console is some random values or int, while it should be 21. What am I doing wrong here?

Edit:
In customEventAction() when I used the following statement:

cout<<eventContent.getValue(4)->getType()<<endl;
cout<<"Event code = "<<eventCode<<endl;

I got the following output:

i
Event code = d

I searched and found that 'i' is the value of EG_INTEGER which means the value I am sending is getting received properly. I am just not been able to convert it back to int. And why the event code is coming as 'd'?


Source: (StackOverflow)

Built-in Multiplayer in Unity3D without a Server?

I heard Unity3D has a Built-In Multiplayer functionality and it can provide the service without a server. But I couldn't find any information about it, all the turtorials I found were just about working with Photon(PUD) or Google Services. I know Photon is good, so I just started to study it and have a plan to use it.

However I still want to write some very simple apps not using servers, something like One VS One Rock Paper Scissors game. Using Photon must be better on performance but in some cases like I said above, it seems to be too much. In addition, CCU of PUD for free users is just twenty, so it means only ten groups can play at the same time, Rock Paper Scissors game, for instance.

I saw some said it's possible without a server, but some other said impossible.

What is right?


Source: (StackOverflow)

Echo on Photon Voice. Even on demo

I'm using Photon Voice feature but I get a lot of echo even on the demo. I need to use the speaker so using headphones is not a solution for me. I have try to raise the voice detection value but it barely helps. Someone have the same problem? Im testing the app on mobile and pc.

Thank you in advance!

EDIT: Removing the audio source of our own prefab, helps a lot but don't solve the problem on some scenarios.

To remove audio source add on class CharacterInstantiation

o.GetComponent<AudioSource> ().enabled = false;

Like this

public new void OnJoinedRoom() {
        if (this.PrefabsToInstantiate != null) {
            GameObject o = PrefabsToInstantiate[(PhotonNetwork.player.ID - 1) % 4];
            //Debug.Log("Instantiating: " + o.name);
            Vector3 spawnPos = Vector3.zero;
            if (this.SpawnPosition != null) {
                spawnPos = this.SpawnPosition.position;
            }
            Vector3 random = Random.insideUnitSphere;
            random = this.PositionOffset * random.normalized;
            spawnPos += random;
            spawnPos.y = 0;
            Camera.main.transform.position += spawnPos;
            o = PhotonNetwork.Instantiate(o.name, spawnPos, Quaternion.identity, 0);
            o.GetComponent<AudioSource> ().enabled = false;
            if (CharacterInstantiated != null) {
                CharacterInstantiated(o);
            }
        }
    }

Source: (StackOverflow)

Send player position to another player to move him in multi player game using Unity Photon

I follow the steps of PUN basic tutorial. For now I reach to a part of what I want Send my position in the current time to another player with me in the room to move him. I can print my position each time I update it , what I need is to know how I can send position to another player to move him. Let's say I have a desktop player and when I move him this translation moving the player on mobile. And how I stop instantiate object on mobile, I just want to deal with the instantiated object on desktop. I am using unity and Photon Network SDK.

Here is the code I used

using UnityEngine;
using System.Collections;

public class NetworkCharacter : Photon.PunBehaviour {

    private Vector3 correctPlayerPos;

    void Update()
    {
        if (!photonView.isMine)
            transform.position = Vector3.Lerp(transform.position, this.correctPlayerPos, Time.deltaTime * 5);

        photonView.RPC ("PrintPosition", PhotonTargets.All, transform.position);
    }

    void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    {
        if (stream.isWriting)
        {
            // We own this player: send the others our data
            stream.SendNext(transform.position);
        }
        else
        {
            // Network player, receive data
            this.correctPlayerPos = (Vector3)stream.ReceiveNext();
        }
    }

    [PunRPC]
    void PrintPosition(Vector3 pos)
    {
        Debug.Log (pos);
        //I need to send position coordinates to the other device
    }
}

The other class of establish multiplayer environment:

using UnityEngine;
using System.Collections;

public class NetworkManager : Photon.PunBehaviour {

    // Use this for initialization
    void Start () {
        PhotonNetwork.ConnectUsingSettings ("0.1");
        //PhotonNetwork.logLevel = PhotonLogLevel.Full;
    }

    void Update () {

    }

    void OnGUI()
    {
        GUILayout.Label(PhotonNetwork.connectionStateDetailed.ToString());
    }

    public override void OnJoinedLobby ()
    {
        Debug.Log("join lobby!");
        PhotonNetwork.JoinRandomRoom ();
    }

    void OnPhotonRandomJoinFailed()
    {
        Debug.Log("Can't join random room!");
        PhotonNetwork.CreateRoom(null);
    }

    void OnJoinedRoom()
    {
        Debug.Log("join random room!");
        GameObject monster = PhotonNetwork.Instantiate("monsterprefab", Vector3.zero, Quaternion.identity, 0);
    }
}

Source: (StackOverflow)

Pubnub library not compiling on Particle Photon

I am trying to publish a message using pubnub on the Particle Photon. The code snippet below comes straight out of the Pubnub example code.

The code will not compile, with the message from the compiler as follows:

PubNub/PubNub.h:87:47: error: expected class-name before '{' token
 class PubSubClient: public PubNub_BASE_CLIENT {
                                               ^

PubNub/PubNub.h: In constructor 'PubSubClient::PubSubClient()':

 PubNub/PubNub.h:23:28: error: class 'PubSubClient' does not have any field named 'WiFiClient'
 #define PubNub_BASE_CLIENT WiFiClient
                        ^

The code for this tiny project is as follows:

// This #include statement was automatically added by the Particle IDE.
#include "PubNub/PubNub.h"

char pubkey[] = "<key here>"; 
char subkey[] = "<key here>"; 
char channel[] = "Channel"; 

void setup() {

    Serial.begin(9600); 
    Particle.publish("Serial set up"); 
    PubNub.begin(pubkey, subkey); 

}

void loop() {

    TCPClient *client; 
    char msg[64] = "{\"photon\":\"on\"}"; 
    client = PubNub.publish(channel, msg); 
    client->stop(); 

    Delay (30000);
}

Has anyone had a similar problem, and if so, can you guide me as to how to fix this.

Thanks.


Source: (StackOverflow)

Photon 2d game multiplayer lags

I have a 2D multiplayer game using Photon where all the movements are made by RigidBody 2d. When both players are connected I can see my opponent movements but they are not smooth. Last Update Time variable is set to 0.25.

using UnityEngine;
using System.Collections;

public class NetworkCharacter : Photon.MonoBehaviour {

    Vector3 realPosition = Vector3.zero;
    Quaternion realRotation = Quaternion.identity;
    public float lastUpdateTime = 0.1f;
    // Use this for initialization
    void Start () {

    }

    // Update is called once per frame
    void FixedUpdate () {
         if(photonView.isMine){
            //Do nothing -- we are moving
        }
        else {
            transform.position = Vector3.Lerp(transform.position, realPosition, lastUpdateTime);
            transform.rotation = Quaternion.Lerp(transform.rotation, realRotation, lastUpdateTime);
        }
    }

    public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info){
        if(stream.isWriting){
            //This is OUR player.We need to send our actual position to the network
            stream.SendNext(transform.position);
            stream.SendNext(transform.rotation); 
    }else{
            //This is someone else's player.We need to receive their positin (as of a few millisecond ago, and update our version of that player.
            realPosition = (Vector3)stream.ReceiveNext();
            realRotation = (Quaternion)stream.ReceiveNext();
        }

    }
}

Source: (StackOverflow)

Client Disconnect with message "Peer Created" - PUN

I am developing multiplayer game in unity using Photon Unity Network plugin. At present, I have completed half of my game. Today I am facing new issue regarding connection of client.

Initially it connects with room but after sometime it automatically disconnected from server and this is happening for every client that was exist in room.

GUILayout.Label(PhotonNetwork.connectionStateDetailed.ToString());

Above statement display Peer Created message on screen and after that

 void OnConnectionFail()
{
    Debug.Log("OnConnectionFail");
}

method gets called.

So what to do in this situation? Because data of this client was lost suddenly.


Source: (StackOverflow)

How to spawn an object by instantiating its prefab via photon unity network - unity 3d

In my multiplayer game, im trying to spawn my player by instantiating it. The error i get when running my program says i am missing the photon view component, yet i have it set to the correct player prefab. Here is my code for my network manager which searches, joins & creates a room when ran. The OnJoinedRoom function is supposed to be spawning my player.

error -'Failed to Instantiate prefab: Player. Prefab must have a PhotonView component.'

code:

using UnityEngine; using System.Collections;

public class NetworkManager : Photon.MonoBehaviour {

// Use this for initialization
void Start () 
{
    PhotonNetwork.ConnectUsingSettings ("version 1.0.0");
}


void OnGUI()
{
    GUILayout.Label (PhotonNetwork.connectionStateDetailed.ToString ());
}

void OnJoinedLobby()
{
    PhotonNetwork.JoinRandomRoom ();
}

void OnPhotonRandomJoinFailed()
{
    PhotonNetwork.CreateRoom (null);
}

void OnJoinedRoom()
{
    GameObject myPlayer = PhotonNetwork.Instantiate ("Player", new Vector3(300, 18, 1496), Quaternion.identity, 0);
}

}

This link is a picture of the players information in the inspector.

http://prntscr.com/4wa8f6


Source: (StackOverflow)