RSS

Tag Archives: C#

Bing Search in C#: A step by step walk-through tutorial


This blog is the 3rd article of the series Search in C# example demonstration. If you are interested in my earlier blogs in this series, please refer to below blogs:

In this blog, I am going to walk through how to do Bing Web Search using the latest v5 API.

BingSearch

Read the rest of this entry »

 
1 Comment

Posted by on December 15, 2016 in Dotnet/C#, Programming

 

Tags: , , , , , , , , , ,

Using SmartFox with C# (III) : Frequently used functions


If you haven’t read below posts, you might wish to have a quick go through:

Using SmartFox with C# (I) : Installations and 1st handshaking
Using SmartFox with C# (II) : Login and join room

If you are comfortable with above implementations, you might be interested in below frequently called functions. Assuming below variable is instantiated successfully:

private SmartFox client;

To Send a message:

client.Send(new PublicMessageRequest(someMessage));
client.AddEventListener(SFSEvent.PUBLIC_MESSAGE, OnPublicMessage);
private void OnPublicMessage(BaseEvent evt) {
     User sender = (User) evt.Params[“sender”];
     string message = (string) evt.Params[“message”];   
}

To create a room:

var settings = new RoomSettings(“New Room Name”);
settings.maxUsers = 100;
Settings.groupId = “ChatGroup”;
client.Send(new CreateRoomRequest(settings));
client.addEventListener(SFSEvent.ROOM_ADD, OnRoomAdded);

For a zone, to join/remove a room:

client.Send(new Sfs2X.Requests.JoinRoomRequest(roomId));
client.AddEventListener(SFSEvent.ROOM_JOIN, OnRoomJoin);
private void OnRoomJoin(BaseEvent evt) {
     Room room = (Room) evt.Params[“room”];           
     //room.Name,  room.UserList
}

For user to enter/leave a room

client.Send(new Sfs2X.Requests.LeaveRoomRequest());
client.AddEventListener(SFSEvent.USER_EXIT_ROOM, OnUserExitRoom);
private void OnUserExitRoom(BaseEvent evt) { User user = (User) evt.Params[“user”]; }

For more information, have a read on SFSEvent class and Sfs2X.Requests namespace will be vey helpful.

 
2 Comments

Posted by on September 14, 2015 in Dotnet/C#, Programming, Unity 3d

 

Tags: , , , , ,

Using SmartFox with C# (I) : Installations and 1st handshaking


Despite that SmartFox has offered a Unity3D package for easy access SmartFox functionalities for game developers, however it is not very straightforward to directly get to know how to consume SmartFox with C# (Mono), particularly in a step-by-step fashion. This post offers a concise introduction on how to get started with SmartFox in C# in 2 minutes. Hope you love it …

Server setup

C# Client

  • Got o SmartFoxServer web site
  • Download the Client API
  • Extract the downloaded zip file, and grab the dll for further use.

Read the rest of this entry »

 
3 Comments

Posted by on September 14, 2015 in Dotnet/C#, Programming, Unity 3d

 

Tags: , , , , , ,

Using RabbitMQ in C# (III) Consuming messages from RabbitMQ


It can be found that In earlier posts, setup RabbitMQ and sending messages are a piece of cake using RabbitMQ C# client. Let’s take a further step and see how to consume messages from RabbitMQ.

Create a console application, and add below code:

public static void Main()
{
        var factory = new ConnectionFactory() { HostName = "…" };
        using (var connection = factory.CreateConnection())
        {
            using (var channel = connection.CreateModel())
            {
//Assuming you have a queue named “whatever” created already
var consumer = new EventingBasicConsumer(channel); consumer.Received += (model, ea) => { var body = ea.Body; var message = Encoding.Default.GetString(body); Console.WriteLine(" [x] Received {0}", message); }; channel.BasicConsume("whatever", true, consumer); Console.WriteLine(" Press [enter] to exit."); Console.ReadLine(); } } }

That is it! Simple?

 
Leave a comment

Posted by on August 17, 2015 in Dotnet/C#, Programming

 

Tags: , , , , , , , , , , , , ,

Using RabbitMQ in C# (II) Sending message to RabbitMQ


Create a Winform application, add below UI to the form:

image

Read the rest of this entry »

 
1 Comment

Posted by on August 13, 2015 in Dotnet/C#, Programming

 

Tags: , , , , , , , , ,