[Visual C#] Client does not create Room.

Options
Xi4
Xi4
edited February 2015 in DotNet
Hello everybody,

I try to make rooms and display a room list within a Visual C# Form Application, but whenever I make a room nothing happens (checked with provided demo tool, no room was created from my client) and getting the Room List also does not work (sometimes getting Error 227)

This is my code
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;

using ExitGames.Client.Photon;
using ExitGames.Client.Photon.LoadBalancing;
using System.Collections;

namespace JumpGrounds_Online___Launcher
{
    public partial class Lobby : MetroFramework.Forms.MetroForm
    {
        private PhotonClient phc;
        private Thread updateThread;

        public Lobby()
        {
            InitializeComponent();
        }

        private void Lobby_Load(object sender, EventArgs e)
        {
            phc = new PhotonClient();
            phc.peerConnect();
        }

        private void updateServerlist()
        {
            LoadBalancingClient client = new LoadBalancingClient(ConnectionProtocol.Udp);
            client.Connect();

            if(client.IsConnected)
            {
                int i = 0;
                string maxp = "";
                foreach(var stringList in client.RoomInfoList.Values)
                {
                    i++;
                    maxp = stringList.PlayerCount + " / " + stringList.MaxPlayers;
                    dataGridView1.Rows.Add(i, stringList.CustomProperties["mapname"], maxp);
                }
            }
            else
            {
                MessageBox.Show("You are not connected, will not update Server list."); // client is never connected, this gets always called
            }
        }

        private void metroTile_CreateQuick_Click(object sender, EventArgs e)
        {
            phc.createTestRoom();
        }

        private void metroButton1_Click(object sender, EventArgs e)
        {
            updateServerlist();
        }

    }

    public class PhotonClient : IPhotonPeerListener
    {
        LoadBalancingPeer peer;

        public bool peerConnect()
        {
            peer = new LoadBalancingPeer(this, ConnectionProtocol.Tcp);
            if (peer.Connect("app.exitgamescloud.com:5055", "MYID"))
            {
                return true;
            }

            return false;
        }

        public void createTestRoom()
        {
            RoomOptions roomOptions = new RoomOptions() { MaxPlayers = 4 };
            peer.OpCreateRoom("Test", roomOptions, TypedLobby.Default, null, false);
        }

        public LoadBalancingPeer getPeer()
        {
            return peer;
        }

        void IPhotonPeerListener.OnEvent( EventData eventData ) 
        {
            
        }

        void IPhotonPeerListener.OnStatusChanged(StatusCode statusCode)
        {

        }

        void IPhotonPeerListener.OnOperationResponse(OperationResponse operationResponse)
        {

        }

        void IPhotonPeerListener.DebugReturn(DebugLevel debugLevel, string msg)
        {
            MessageBox.Show(msg);
        }
    }
}

Can anyone tell me what I am doing wrong? The demo application (loadbalancer) works fine.

Regards,
Xi4.

Comments

  • vadim
    Options
    Hi,

    Do you have any errors in log?
    Are you sure that client connected to the lobby when trying to create room?
    As far as I know demo uses app-eu.exitgamescloud.com:5055 server.
  • Xi4
    Options
    Hello,

    I already fixed the issue, I forgot to use the Service() function to refresh data.