Good Afternoon All,
Urgent Request....
Is it possible to post a integration example or white paper on how to actually setup a connection between SFS and .Net (c#). Doesnt matter how basic it is, just being able to hook in to an event in .net is really all I need. It also doesnt matter what the project type is, winapp or web app... thanks. I have no need for Unity support.
.Net C# Integration Example Needed
-
- Posts: 1297
- Joined: 14 Mar 2008, 07:52
- Location: Sweden
Here's an example:
It basically go through the initial setup:
1- connect
2- login
3- join a room
and finally send a public message.
You don't need any particular server setup as it uses the default "simpleChat" zone.
Hope it helps
Code: Select all
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SmartFoxClientAPI;
using SmartFoxClientAPI.Data;
namespace SFSTest1
{
class Program
{
SmartFoxClient sfs;
public Program()
{
sfs = new SmartFoxClient();
SFSEvent.onConnection += OnConnection;
SFSEvent.onLogin += OnLogin;
SFSEvent.onJoinRoom += OnJoinRoom;
SFSEvent.onPublicMessage += OnPublicMessage;
Trace("Connecting...");
sfs.Connect("127.0.0.1", 9333);
}
public void OnConnection(Boolean success, String error)
{
if (success)
{
Trace("Connected");
sfs.Login("simpleChat", "", "");
}
else
Trace("Failed Connecting!");
}
public void OnLogin(Boolean success, String name, String error)
{
if (success)
{
Trace("LOGIN OK");
sfs.AutoJoin();
}
else
Trace("LOGIN KO!");
}
public void OnJoinRoom(Room room)
{
Trace("ROOM JOINED: " + room.GetName());
sfs.SendPublicMessage("Hello from dotNet!");
}
public void OnPublicMessage(string message, User sender, int roomId)
{
Trace("-----> PUB MSG: " + message + ", from: " + sender.GetName());
}
private void Trace(string msg)
{
Console.WriteLine(msg);
}
static void Main(string[] args)
{
new Program();
Console.WriteLine("Waiting for a key...");
Console.ReadKey();
}
}
}
It basically go through the initial setup:
1- connect
2- login
3- join a room
and finally send a public message.
You don't need any particular server setup as it uses the default "simpleChat" zone.
Hope it helps
Return to “.Net / Unity3D API”
Who is online
Users browsing this forum: No registered users and 35 guests