Quantcast
Channel: JavaScript and TypeScript — Photon Engine
Viewing all 162 articles
Browse latest View live

Cache and Custom Room Property Limits

$
0
0
-- The docs state there is a limit on the total number of cached events in a room (global cache plus actor caches). What is the value of that limit?

-- Is there a total cache size limit as well?

-- What is the size limit for custom room properties?

How to remove/replace an event in the global cache?

$
0
0
According to the cached events documentation it is possible to remove events from the global cache, but I have been unable to find an API that accomplishes that. The list of available event caching values shows a value for adding to the global cache, but not a corresponding value for removing or replacing an event in the global cache. How do I accomplish this?

Photon does not connect to servers in HTML5

$
0
0
I have a project in construct2 that works fine when previewing, when exporting to NW.js, but when I upload the HTML archive to itch.io and Scirra Arcade, I don’t have a connection to the server there

Disconnecting From Server When in Background iPhone

$
0
0
Hi, I am experiencing an issue with a turn-based game that I built using Photon Server SDK and Javascript SDK(used to connect the Client to Photon Server) on iPhone.
Whenever in iPhone my app goes in the background and it comes in Foreground even within 5 seconds It gets disconnected from the server and the whole app freezes.
Sometimes it does get reconnected after 10-15 seconds sometimes we have to close the app completely and then reopen it to join back into the room.
I need suggestions on the following:
1. Is there a parameter or a value that we can increase so that player gets disconnected after some more time.
2. How can I detect that player is disconnected from Javascript SDK and how can I make a reconnect request as soon as app comes in the foreground.
3. Can I prevent the app from disconnecting when It goes in the background in iPhone

Thanks

does not work on all browsers except mozilla

$
0
0

Console:
Uncaught (in promise) TypeError: Cannot read property 'ConnectionProtocol' of undefined
at new PhotonInstance (957d42b1-209f-4400-87db-54be8fd65cc3:176)
at Function.f.New (jsutil.js:1)
at C3.Instance._CreateSdkInstance (instance.js:1)
at C3.ObjectClass._CreateSingleGlobalInstance (objectClass.js:1)
at new C3.ObjectClass (objectClass.js:1)
at Function.f.New (jsutil.js:1)
at Function.Create (objectClass.js:1)
at C3.Runtime._LoadDataJson (runtime.js:1)
at C3.Runtime.Init (runtime.js:1)
at async a (b935f49c-40a9-4b06-b903-dd5af33b87c3:1)


I tried to set both WS and WSS protocol, but it did not work

Example code

$
0
0
Has anyone made any examples beyond the ones provided by photon? I'm having a hard time finding any examples that work with javascript.

What is the difference between .raiseEvent() of Actor() and LoadbalancingClient()?

$
0
0
There seems to be .raiseEvent() function for both Actor() and LoadBalancingClient(). I'm curious as to which I should use in different scenarios?

Photon and Photon Voice for PlayCanvas?

$
0
0
Do you have any plans for bringing official Photon support for PlayCanvas (https://playcanvas.com/) which is a WebGL game engine.

And what about Photon Voice? I would love to be able to use Photon Voice in a browser game.

Looking for a simple barebones messaging

$
0
0
Hey guys, I'm still new to the photon engine and was trying to see if I could find a easy chat script that I could mess around with and get a feel for. I've tried searching a bit myself but most of what I get back are peoples games and the like. Any kind of information or direction would be super helpful!

Can I run Photon Server on other Internet server?

$
0
0
I use Photon in my Construct 2 project and want to host it on the server of my site. How do I do that? Must the server be on Windows base only or Linux will work as well?

Thanks

Room properties blank

$
0
0
Just starting out with the Javascript SDK in Playcanvas. I would like to use room properties to communicate damage/pickups for scene objects so that clients joining later get all the same info.

If I join a room with two players in separate browsers, when I test setting custom properties on the current room with this:
this.photon.currentRoom.setCustomProperty(id, amount);
(id is the predetermined scene object's id, amount is how much damage is being applied)

Both players receive a response from this:
this.currentRoom.onPropertiesChange = function(change, byClient) {
console.log("onPropertiesChange:", change, byClient);
};

However, in onPropertiesChange the change variable is populated with the correct info on the player that did the damage, while on the other player the change object is empty. I also tried debugging currentRoom._customProperties and it had the same problem (data populated on player that did it, blank for other player).

Is this expected behavior? Should I be using some other method?

How is joinRandomRoom() supposed to fail?

$
0
0
I am making a browser multiplayer game and using Photon Realtime javascript SDK.

The docs state that joinRandomRoom "fails if all rooms are closed or full." (https://doc-api.photonengine.com/en/javascript/current/Photon.LoadBalancing.LoadBalancingClient.html#joinRandomRoom)

But the docs have no information on what happens in failed case. Will it throw an exception? Or return false? Or raise some onJoinRandomRoomFailed event?

At least in my case it seems to always return true and never throws an exception.

So how am I supposed to know if join random room fails?

How do I connect Photon Server with Construct 2?

$
0
0
image.png

Where exactly can I get the data to fill the gaps?
It didn't work out with my server ip so I'm here to find out what's wrong :smile:

Construct 3 photon.c3addon Cannot read property 'ConnectionProtocol' of undefined

$
0
0
Hi.
I'm trying to make multiplayer work, in the test project.
Im using Construct 3 and photon.c3addon (https://www.photonengine.com/en-US/sdks#realtime-sdkrealtimeconstruct2).

When I export project to html and upload it to the server its working fine (http://alfateam.cal24.pl/test/c2/)

But when I export it to the Desktop nodejs application it doesn't work.

In console I see error:
Uncaught (in promise) TypeError: Cannot read property 'ConnectionProtocol' of undefined
at new PhotonInstance (28f41174-bad8-4c57-99ec-e625e0538980:176)
at Function.New (jsutil.js:9)
at Instance._CreateSdkInstance (instance.js:7)
at ObjectClass._CreateSingleGlobalInstance (objectClass.js:12)
at new ObjectClass (objectClass.js:7)
at Function.New (jsutil.js:9)
at Function.Create (objectClass.js:7)
at C3Runtime._LoadDataJson (runtime.js:28)
at C3Runtime.Init (runtime.js:21)
at async InitRuntime (c0f29e65-1153-4271-a7be-e4d4e496c719:4)

Operation 227 - failed, "isConnected" is false , "isClosing" is false

$
0
0
I have a 1 vs 1 multiplayer browser game where I am utilizing Photon Realtime JS SDK. I have a system where I detect other player from leaving the browser tab (with Page Visibility API). Now, I want to make is so that if the other player remains inactive (on the other browser tab) for 10 seconds, he/she will be disconnected.

All works fine, but when I call leaveRoom() on the client that is inactive, I get error "Operation 227 - failed, "isConnected" is false , "isClosing" is false".

Is this because somehow the server already knows that the client is not connected? And what is the workaround?

How to use best region in Photon Realtime Javascript SDK

$
0
0
According to https://doc.photonengine.com/zh-tw/realtime/current/connection-and-authentication/regions#best_region_selection there is a way to select best region in Photon Realtime (at least for C#). But how to do the same thing in javascript? I am unable to find example code anywhere or even info on if this is even possible with the Javascript SDK.

In the docs (https://doc-api.photonengine.com/en/javascript/current/Photon.LoadBalancing.LoadBalancingClient.html) there is only connectToRegionMaster() function that takes the region to connect as parameter explicitly.

I am creating a browser based game for world wide audience and it is important to auto-select the region with the lowest ping. How do I achieve this? Do I have to somehow manually ping all the region masters?

Matchmaking in JS, send users to Unity

$
0
0
Howdy...

I am making a game in unity and wanted to make a game client that loads it up. I have an electron + angular app that I code in JS/TS. It handles authentication, out of game store, etc. It is able to obtain a custom JWT token and pass that to my unity client, which uses this to get user info from another service I have.

What I'd like to do is handle matchmaking within my JS app and once the match has been found and players have selected their loadout, send them to unity with the photon game id and any connection information needed.

I've been looking through the realtime JS sdk docs, and it just looks like chat and load balancing is there. Alternatively, if there was a RESTful api, I could make calls to that.

Is such a thing possible?

Connecting server with playfab

$
0
0
I am trying to realtime cloud server with playfab (JavaScript API). Using appID generated by playfab, I can get Photon Authentication Token, but I have no idea how to setCustomAuthentication. Below code results in "Client: Error: 3101 NameServer authentication failed" var client = new Photon.LoadBalancing.LoadBalancingClient(Photon.ConnectionProtocol.Ws, APPID, "1.0"); var authParam = "username=user1" + "&token=" + TOKEN; client.setCustomAuthentication(authParam, Photon.LoadBalancing.Constants.CustomAuthenticationType.Custom); client.connectToRegionMaster("EU"); Can anybody help me?

Connecting Unity and JS clients to the same room.

$
0
0
I am trying to make a very simple web client which can connect to a room created in PUN to listen for some events display information in the web client.

However I cannot seem to get the web client to see or connect to any of the rooms created by PUN.

I confirmed I am using the same app id, app version, and region.

PUN clients can connect to rooms created by other PUN clients, and likewise JavaScript clients can connect to rooms created by other JavaScript clients.

Am I missing something obvious?

I am happy to post my code if that is helpful.

Thanks in advance for any help

Photon Realtime + React?

$
0
0
Hello! Apologies if this has been answered before but the docs seem pretty sparse and I searched the forum and haven't found an answer.

I'm trying to add Photon to my ReactJS app. Currently I'm doing the following:
import "./Photon/Photon-Javascript_SDK.js";
import React, { createContext, useEffect, useState } from 'react';

const App = () => {

  useEffect(() => {
      var client = Photon.LoadBalancing.LoadBalancingClient);
  }, []) 



(Removed some code of course.) But I'm getting this error:
'Photon' is not defined  no-undef
I've tried about a million ways of including the sdk. Anybody know what I might be doing wrong?
Viewing all 162 articles
Browse latest View live