Photon creating new room instead of connecting to already existing one? - unity3d

When I create a build of the game, everything works normally. However, when the second player tries to connect to the room with the name, it says that the room does not exist and if I create a room with the first rooms name it gets created instead of saying "room already exists".
I thought it could be a region problem, but in PhotonServerSettings, the "Fixed Region" is set to "eu", "Use Name Server" checked on, and "Dev Region" set to null (left it empty). In the build settings I set "development build" to false.
I don't understand why the two games would not be in the same region based on what I mentioned before?
Picture of the PhotonServerSettings
This is the code for creating/joining a room:
public void CreateRoom()
{
if (string.IsNullOrEmpty(CreateInputField.text))
{
return;
}
PhotonNetwork.CreateRoom(CreateInputField.text);
}
public void JoinRoom()
{
if (string.IsNullOrEmpty(JoinInputField.text))
{
return;
}
PhotonNetwork.JoinRoom(JoinInputField.text);
}
public override void OnJoinedRoom()
{
PhotonNetwork.LoadLevel("Game");
}
public override void OnCreateRoomFailed(short returnCode, string message)
{
failText.text = message;
}
public override void OnJoinRoomFailed(short returnCode, string message)
{
failText.text = message;
}
}
(for some reason I cant put the entire script but these are the important parts)

Related

Unity & PhotonEngine. After scene reaload Joining to Lobby, CreateRoom and JoinRandom functions called repeatedly

I ran into a problem in the last step of a test project using Photon Network. When you first connect and join the room, everything goes without errors. However, after completing the match, exiting the room, and using LoadScene(), errors appear:
JoinLobby operation (229) not called because client is not connected or not yet ready, client state: JoiningLob <- in OnConnectedToMaster()
Through experience, I realized that the ConnectUsingSettings() methods and other Photon methods are called multiple times. But the connection to the lobby happens and I can create a room, but I immediately encounter MissingReferenceException errors.
I've seen a solution from guys who ran into this very same problem. The problems arose because of the events. Wherever this could happen, I unsubscribed from the events, but that doesn't help. What else can cause such problems, because I obviously missed something that prevents me from completely closing the scene during the transition?
Sorry for my language, used Google Translate
Code:
LobbyManager.cs
private void StartConnect()
{
PhotonNetwork.NickName = master.GameSettings.NickName;
PhotonNetwork.GameVersion = master.GameSettings.NickName;
PhotonNetwork.ConnectUsingSettings();
PhotonNetwork.AutomaticallySyncScene = true;
}
public override void OnConnectedToMaster()
{
Debug.Log("Connected to server");
if(!PhotonNetwork.InLobby) PhotonNetwork.JoinLobby();
}
public override void OnJoinedLobby()
{
onConnected.Invoke();//This use for show UIElements on Canvas
}
JoinRandomRoom class
public void OnClick_JoinRandomRoom()
{
if (!PhotonNetwork.IsConnected) return;
if (GameModeGlobalData.SelectedGameMode != null)
{
SetRoomOptions();
PhotonNetwork.JoinRandomRoom(expectedRoomProperties, GameModeGlobalData.SelectedGameMode.MaxPlayers);
}
}
public override void OnJoinRandomFailed(short returnCode, string message)
{
Debug.Log("Join random failed: " + message + ". Room will be created...");
_createRoomMenu.CreateAndJoinRoom();
}
public void SetRoomOptions()
{
expectedRoomProperties[RoomData.GAME_MODE] = GameModeGlobalData.SelectedGameMode.GameModeName;
}
private void OnDisable()
{
ShowPanels.RemoveAllListeners();
}
And CreateRoom.cs
private ExitGames.Client.Photon.Hashtable _roomCustomProperties = new ExitGames.Client.Photon.Hashtable();
public void CreateAndJoinRoom()
{
if (!PhotonNetwork.IsConnected) return;
if (GameModeGlobalData.SelectedGameMode != null)
{
RoomOptions roomOptions = GetCustomRoomOptions();
roomOptions.CleanupCacheOnLeave = true;
PhotonNetwork.CreateRoom(randomRoomName, roomOptions);
}
}
public RoomOptions GetCustomRoomOptions()
{
RoomOptions options = new RoomOptions();
options.MaxPlayers = _maxPlayer;
options.IsOpen = true;
options.IsVisible = true;
string[] roomProperties = new string[]{ RoomData.GAME_MODE };
_roomCustomProperties[RoomData.GAME_MODE] = GameModeGlobalData.SelectedGameMode.GameModeName;
options.CustomRoomPropertiesForLobby = roomProperties;
options.CustomRoomProperties = _roomCustomProperties;
return options;
}
The project has grown, and I blame myself for not testing it at the very beginning. Didn't think there would be problems at this stage
Sorry for this post. Its resolved. For those who may encounter this in the future, in addition to unsubscribing from events, check all classes that inherit from MonoBehaviourPunCallbacks for overridden OnDisable() methods.
Like this:
public override void OnDisable()
{
base.OnDisable();
}
This in turn will call the
PhotonNetwork.RemoveCallbackTarget(this);
Also, from the documentation:
Do not add new MonoBehaviour.OnEnable or MonoBehaviour.OnDisable. Instead, you should override those and call base.OnEnable and base.OnDisable.
I forgot about it and used MonoBehaviour.OnDisable.

Photonview.owner.nickname not working properly for Clients

I'm working on photon game where I have to show the player name over their everything is working fine but there's an issue , when you create a room and join it , the host name is properly visible to everyone but when it comes to the client Client name is some random numbers even though client is also setting their user name before joining the room , here's my code which is handling the naming system
public void JoinRoom()
{
connectButton.interactable = false;
PhotonNetwork.NickName = userId.text;
PhotonNetwork.JoinRoom("Basic");
}
Try this
PhotonView view;
void Start()
{
view = GetComponent<PhotonView>();
}
void JoinRoom()
{
if(view.IsMine)
{
userId.text = PhotonNetwork.NickName;
}else
{
userId..text = view.Owner.NickName;
}
}

Mirror/UNET c# - No authority on object even when using Command & ClientRpc - What am I missing?

Long story: I have made a multiplayer chat using Mirror/Unet that works. I have made it so after x number of seconds, the gameobject that displays the chat (“textContainer”) goes inactive. I would like it so that when client 1 presses “Submit”, all the client’s gameobjects for textContainer goes active again. But it only works on the client that presses Submit, and not on ALL clients. I have set up the functions in [Client] [Command] and [ClientRpc] but am still getting an error about no authority on object.
I think it is because client 1 does not have authority to request client 2 to activate their UI panel. I thought the Command and ClientRpc would have fixed this issue?
Short story: So, for simplicity, say when client 1 presses the Input for “Submit”, I would like all client’s textContainer GameObjects to go active.
I am hoping someone might be able to point me in the right direction. Cheers.
This script would be attached to the player prefab.
public GameObject textContainer;
[Client]
void Update()
{
if (Input.GetAxisRaw("Submit") == 1)
{
CmdActivateChatClientRPC();
textContainer.SetActive(true);
}
}
[Command]
private void CmdActivateChatClientRPC()
{
ActivateChatClientRPC();
}
[ClientRpc]
private void ActivateChatClientRPC()
{
textContainer.SetActive(true);
}
You are not checking whether you have the authority over this object.
void Update()
{
// Does your device have the authority over this object?
// only then you can invoke a Cmd
if(!hasAuthority) return;
if (Input.GetAxisRaw("Submit") == 1)
{
CmdActivateChatClientRPC();
textContainer.SetActive(true);
}
}
[Command]
private void CmdActivateChatClientRPC()
{
ActivateChatClientRPC();
}
// This will be executed on ALL clients!
// BUT only for this one instance of this class
[ClientRpc]
private void ActivateChatClientRPC()
{
textContainer.SetActive(true);
}
If it is rather about only you trying to invoke a command on an object that belongs to the server it gets tricky ;)
You will have to relay the command through your local player object and then on the server forward the call to the according object e.g. referencing the actual target via it's Network identity.
To me it sounds a bit like you are having each player prefab has this class and you want to invoke the RPC on all of them.
This is something that can only be done by the server like e.g.
void Update()
{
// Does your device have the authority over this object?
// only then you can invoke a Cmd
if(!hasAuthority) return;
if (Input.GetAxisRaw("Submit") == 1)
{
CmdActivateChatClientRPC();
textContainer.SetActive(true);
}
}
[Command]
private void CmdActivateChatClientRPC()
{
foreach (var player in NetworkManager.singleton.client.connection.playerControllers)
{
if (player.IsValid)
{
player.gameObject.GetComponent<YourScriptName>().ActivateChatClientRPC();
}
}
}
Seems that .client.connection.playerControllers was removed.
I guess in that case you would need a custom NetworkManager and keep track of them yourself via OnServerConnect and OnServerDisconnect somewhat like
public CustomNetworkManager : NetworkManager
{
public static readonly HashSet<NetworkConnection> players = new HashSet<NetworkConnection>();
public override void OnServerConnect(NetworkConnection conn)
{
base.OnServerConnect(conn);
players.Add(conn);
}
public override void OnServerDisconnect(NetworkConnection conn)
{
base.OnServerDisconnect(conn);
players.Remove(conn);
}
}
and then instead access
foreach (var player in CustomNetworkManager.players)
{
player.identity.GetComponent<YourScriptName>().ActivateChatClientRPC();
}
How about
client->server: request to activate
and then
server->client: singal
[SyncVar(hook = nameof(AcivateText))]
bool textActivated = false;
[Command]
private void CmdActivateChatClientRPC()
{
ActivateChatClientRPC();
}
void AcivateText(bool oldval, bool newval)
{
textContainer.SetActive(newval);
}

Inconsistency in cucumber execution

There are two inconsistencies in my execution.
1) As per the following scenario, "And Click Create Customer" annotation doesn't work correctly. I've updated it before instead of the expression included "#Then("Musteri Olustur tabina tikla ve acilan sayfada submit butonuna tikla")" and once i try to execute it by performing run as feature file with right click, somehow I'm still getting error about previous annotation (the one starting #Then).
2) Second issue is the sixth step of the scenario is not being executed at all. ("Then Type customer information")
How is this possible ?
First four step is working correctly.
Feature: Create Customer
Scenario: Create Prepaid Customer Turkish Citizen
Given Access to LegacyCRM
When Type your username and password
And Click login button
Then Verify that legacycrm is opened
And Click Create Customer
Then Type customer information
-
public class CucumberCustomer {
WebDriver driver;
#Given("^Access to LegacyCRM$")
public void AccessLCRM (){
File file = new File("C:/Users/wiprofkaymaz/Desktop/ie32/IEDriverServer.exe");
System.setProperty("webdriver.ie.driver",file.getAbsolutePath());
driver = new InternetExplorerDriver();
driver.get("https://iccbcf/TelsimGlobal/Menu/showLogin.jsp");
}
#When("^Type your username and password$")
public void TypingLoginInformations(){
driver.findElement(By.xpath("//input[#name='username']")).sendKeys("wiprobaslan");
driver.findElement(By.xpath("//input[#type='password']")).sendKeys("Voda123456789**");
}
#And("^Click login button$")
public void ClickLoginButton(){
WebElement login=driver.findElement(By.xpath("//input[#src='/TelsimGlobal/Menu/image3.gif']"));
login.click();
}
#Then("^Verify that legacycrm is opened$")
public void legacycrmverification(){
driver.switchTo().frame("ax");
driver.switchTo().frame("menu");
boolean vry =driver.findElement(By.xpath("//img[#src='images/vodafone_logo_top.gif']")).isDisplayed();
if(vry){
System.out.println("application has been opened");
}
else{
System.out.println("something wrong");
}
}
#And("^Click Create Customer$")
public void Customercreatev1(){
driver.findElement(By.xpath("//a[#title='Müşteri Oluşturma']")).click();
driver.switchTo().defaultContent();
driver.switchTo().frame("cx");
driver.findElement(By.xpath("//input[#name='Submit']")).click();
}
#Then("^Type customer information$")
public void Customercreatev2() throws InterruptedException{
driver.switchTo().defaultContent();
driver.switchTo().frame("cx");
driver.findElement(By.xpath("//input[#name='name']")).sendKeys("KEM");
driver.findElement(By.xpath("//input[#name='lastname']")).sendKeys("KEM");
Select selectObject = new Select (driver.findElement(By.xpath("//select[#name='day']")));
selectObject.selectByValue("10");
Thread.sleep(1000);
Select selectObject2 = new Select (driver.findElement(By.xpath("//select[#name='month']")));
selectObject2.selectByValue("10");
Thread.sleep(1000);
Select selectObject3 = new Select (driver.findElement(By.xpath("//select[#name='year']")));
selectObject3.selectByValue("1950");
Thread.sleep(1000);
String mainWindow = driver.getWindowHandle();
driver.findElement(By.xpath("//input[#name='iddistrict']")).sendKeys("ADANA");
driver.findElement(By.xpath("//input[#name='fathername']")).sendKeys("BABA");
driver.findElement(By.xpath("//input[#name='Submit']")).click();
Windows(driver, mainWindow);
driver.switchTo().window(mainWindow);
}
public void Windows (WebDriver driver, String mainWindow) {
mainWindow = driver.getWindowHandle();
Set<String> totalwindowsIds = driver.getWindowHandles();
int a=0;
String[] myset = totalwindowsIds.toArray(new String[totalwindowsIds.size()]);
if(myset[a].contains(mainWindow)){
driver.switchTo().window(myset[a+1]);
}
else{
driver.switchTo().window(myset[a]);
}
}
}

Probably a really dumb MassTransit misunderstanding

I'm a new to MassTransit and one thing I don't understand is this:
How do you create a bus between multiple .net ServiceBuses?
Take this code:
class Program
{
static void Main(string[] args)
{
var container = new WindsorContainer();
container.Register(AllTypes.FromThisAssembly().BasedOn<IConsumer>());
Console.WriteLine("Starting Buses!");
var bus1 = ServiceBusFactory.New(sbc =>
{
sbc.UseMsmq();
sbc.UseMulticastSubscriptionClient();
sbc.ReceiveFrom("msmq://localhost/bus1");
sbc.Subscribe(s => s.LoadFrom(container));
});
var bus2 = ServiceBusFactory.New(sbc =>
{
sbc.UseMsmq();
sbc.UseMulticastSubscriptionClient();
sbc.ReceiveFrom("msmq://localhost/bus2");
sbc.Subscribe(s => s.LoadFrom(container));
});
bus1.Publish(new TestMsg() { Name = "Hello Matt!" });
Console.WriteLine("Sent Message");
Console.ReadLine();
}
}
public class TestMsg
{
public string Name { get; set; }
}
public class TestMsgConsumer : Consumes<TestMsg>.All, IBusService
{
private IServiceBus bus;
public void Consume(TestMsg message)
{
Console.WriteLine("Got message on " + this.Context().Endpoint.Address);
}
public void Dispose()
{
if (bus != null)
bus.Dispose();
}
public void Start(IServiceBus bus)
{
this.bus = bus;
}
public void Stop()
{
}
}
I would expect the "Got message on ..." to show up twice, since I have two buses. However, I only get one. Obviously there is some step that ties these two Bus instances to the same logical bus I'm not understanding what that is. I can't point them at the same queue name since, again, only one would get the message.
Thanks!
EDIT/SOLUTION:
I got some help from the MT Google Groups and they got me straightened away quickly... this wasn't working as expected because I didn't have the multicast bits of MSMQ installed. Got those installed and it worked as expected.
See the original post for the answer, but it basically came down to not having the Multicast bits of MSMQ installed. Put those in and all works as expected.