C# processEvent Visual Studio WinFormApplication

Post here your questions about the Unity / .Net / Mono / Windows 8 / Windows Phone 8 API for SFS2X

Moderators: Lapo, Bax

sandratra
Posts: 7
Joined: 31 Mar 2016, 13:47

C# processEvent Visual Studio WinFormApplication

Postby sandratra » 12 May 2016, 13:22

Hi!
I'm using SmartFox2x .dll from release/Windows_universal to make my app.

The problem is on: new ExtensionRequest(...), in Unity it works perfectly when smartFox.ThreadSafeMode = true and smartFox.ProcessEvents() is called in Update(). It's mean that the requests are sended with no problem but in Windows Form application, it doesn't work.

My code to test an request is called after clicking on a button

Code: Select all

private void settingBtn_Click(object sender, EventArgs e)
{
      smartFox.Send(new ExtensionRequest("lobby.infoUser", null, smartFox.GetRoomByName("The Lobby")));
}


How can i do to make it work in Windows form application? I've tried it by using Thread but no issue.
I use Visual studio 2015
Thanks a lot! and sorry for the bad English :)
User avatar
Bax
Site Admin
Posts: 4609
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: C# processEvent Visual Studio WinFormApplication

Postby Bax » 12 May 2016, 14:10

In Windows you have to set SmartFox.ThreadSafeMode to false. This way you don't even need to call the SmartFox.ProcessEvents method.
What is not working with your code exactly? If everything else (connection, login, etc) works, also the Extension request should work.
Did you check the server? Maybe an error is logged when it receives your request, and the response is not sent by your Extension.
Paolo Bax
The SmartFoxServer Team
sandratra
Posts: 7
Joined: 31 Mar 2016, 13:47

Re: C# processEvent Visual Studio WinFormApplication

Postby sandratra » 12 May 2016, 17:00

Thank you verry much!
I solve the problem, my wrong method is that i put The Lobby as roomExtension target but the extension is puted in zone so this is the new code even if I'm in lobby:

Code: Select all

private void settingBtn_Click(object sender, EventArgs e)
{
     smartFox.Send(new ExtensionRequest("lobby.infoUser", new SFSObject()));
     Console.WriteLine("info sended");
}

and i think that SmartFox has useful feature like:
- i'm in lobby
- lobby have ExtensionA
- I need to contact ExtensionB in Zone
- I can do it like new ExtensionRequest("extB.request",null)

And so thanks for replay! :wink:
User avatar
Bax
Site Admin
Posts: 4609
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: C# processEvent Visual Studio WinFormApplication

Postby Bax » 13 May 2016, 07:20

What you suggest can already be done: when sending an ExtensionRequest, if you pass the third parameter (Room), you are communicating with the Extension attached to that Room. If you don't pass the parameter, you are communicating with the Extension attached to the Zone.
Paolo Bax
The SmartFoxServer Team

Return to “SFS2X C# API”

Who is online

Users browsing this forum: No registered users and 29 guests