Archive for October, 2010

Simple Chat Application:Part- 5

October 30th, 2010 by admin | No Comments | Filed in Simple Chat Application : Flash CS4

In handleSmartFoxEvents() function we have called  following functions

//Here we are going to handle all the smartfoxEvents  for now here I am showing  6 function later

We will need to add more.




private function handleSmartFoxEvents():void{

smartFoxObject.addEventListener (SFSEvent.onExtensionResponse, onExtensionResponse);

smartFoxObject.addEventListener(SFSEvent.onRoomListUpdate, onRoomListUpdate)

smartFoxObject.addEventListener(SFSEvent.onUserCountChange, onUserCountChange)

smartFoxObject.addEventListener(SFSEvent.onJoinRoom, onJoinRoom)

smartFoxObject.addEventListener(SFSEvent.onJoinRoomError, onJoinRoomError)

smartFoxObject.addEventListener(SFSEvent.onPublicMessage, onPublicMessage)

smartFoxObject.addEventListener(SFSEvent.onPrivateMessage, onPrivateMessage)

smartFoxObject.addEventListener(SFSEvent.onUserEnterRoom, onUserEnterRoom)

smartFoxObject.addEventListener(SFSEvent.onUserLeaveRoom, onUserLeaveRoom)

smartFoxObject.addEventListener(SFSEvent.onLogout, onLogout)

}


Now lets discuss it in detail :

onExtensionResponse() : this  will give us all server responses defined in the server side. Dispatched when a command/response from a server-side extension is received.

onRoomListUpdate(): this event  is dispatched when the list of rooms of  the current zone is received.
If the default login mechanism provided by SmartFoxServer is used, then this event is dispatched right after a successful login.

onUserCountChange(): this event is dispatched when the number of users and/or spectators changes in a room of the current zone. This event allows to keep track in real-time of the status of all the zone rooms in terms of users and spectators. If any user joins or leave the room it gets updated automatically.

onJoinRoom (): this event is dispatched when a user joins any room  successfully

onJoinRoomError(): while joining a room any error occurs, this event is dispatched. This error could happen, for example, if the user is trying to join a room which is currently full  it will throw an error.In our application we would like to trace the error  so we will get using evt.params.error

onPublicMessage(): this event is dispatched when a user  want to send a public message for all the users.

onPrivateMessage ():this event is dispatched when a user  want to send a public message for all the users.

onUserEnterRoom(): this event is dispatched when another user joins the current room.

onUserLeaveRoom(): this event is dispatched  when a user leaves the current room. This  event is also dispatched when a user gets disconnected from the server.

onLogout (): Dispatched when the user logs out successfully. After a successful logout the user is still connected to the server, but he/she has to login again into a zone, in order to be able to interact with the server. When a user will want to logout from the screen he will need to click on the logout button. On clicking log out button this function will be called.

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

Simple Chat Application:Part 2

October 18th, 2010 by admin | No Comments | Filed in Simple Chat Application : Flash CS4, SmartFox Server

As discussed in our last chapter lets move to the code part more deeply :)

So now we need to load the config and establish the connection first  our code will look like this

ChatManager

Lets start with init() function where I am initializing the smartfoxserver’s object and loading the config.

loadConfigData():- Here I am loading the configData which is basically an XML file out side in the folder

containg ip, zone and port.

onConfigLoaded(): This function is called after successful loading of config XML. Inside this function I am calling two more functions named connectionEventsOfSFS() and handleConnectionToSFS().

connectionEventsOfSFS():- here basically I am enabling the SmartFoxServer’s event for onConnection established and on connection lost.

Tags: , , , , , , , , ,

Simple Chat Application : Flash CS4 (Action Script 3.0)

October 10th, 2010 by admin | 1 Comment | Filed in SmartFox Server

Now we are going to develop a Chat application :)

Step 1 :  Server side :

C:\Program Files\SmartFoxServerPRO_1.6.6\Server

Open the Program Files folder inside that folder you will get SmartFoxServer’s   Server folder where we have to edit the config or create your own config. I am modifying the already created config according to my requirement.

chatapp

Step 2:  Add zone for the application :

zoneChatconfig

Here I am defining the zone name as “Simple Chat” where uCountUpdate is  counter for the number of  user . In Rooms tag as I need only one room for chatting so I have used one room as “The  Hall” , in maxUsers tag I have specified it 50 you can modify it according to your requirement and stated it public so that everyone can join it. For this I am using the extension name “chat” and the file “chat.as”. Well the chat.as is not going to do much for now but in later when I will extend this tutorial it will help us to make a follow.

serverChatExtenstion

Step 3:  Start the server

Now we need to start the server where in console you will get trace and the created zone. Something similar to this will be shown:

chatserverConsole

Step 4: Client Side

Now the time is for client side adventure :) . As I am going to create a chat application definitely I will need some specific screens.

connectionScreen

In the first layer of Fla  I have created the connection status movie clip named connectionStatus_MC where I have taken a dynamic text box statusMsg_txt which will show status of connection with server. On load automatically we will send the connection request to the server.

loginScreen

After connection we will need on more screen for  Login. So I have created this screen. I have named this login_mc. I have used one input text box loginName_txt where user will enter his name to join the chat and butt_login to send the request to the server.

chatwindow

Lets now design the Chat Screen here I have taken 3 sub panels. One is for Chat window chatWindow_mc, second is for user list (List component) user List_mc and third one is for the message window (msg_txt) and send button butt_send as message pad. One more button is there for butt_logOut if user wish to logout he can click on the Log Out button.

Okay .. so Now it is enough design work lets move towards the CODE  :)

So I am starting with a document class ChatManager .  The initially it will look like this

ClientSideChatCode

will move forward with the code in next chapter :)

Custom Login : Flash CS4 (Action Script 3.0)

October 10th, 2010 by admin | 2 Comments | Filed in SmartFox Server

I would like to provide the tutorial using Flash and Flex both. The first I am starting with Flash CS4 using Action script 3.0.

Step 1 :  Server side :

C:\Program Files\SmartFoxServerPRO_1.6.6\Server

Open the Program Files folder inside that folder you will get SmartFoxServer’s   Server folder where we have to edit the config or create your own config. I am modifying the already created config according to my requirement.

1a

Step 2:  Add zone for the Custom login :

b

I have added a zone named “login” in the server side config where I am defining emptyNames as false value and customLogin will be on. As I need one room so I have created it “The Hall” where maximum number of users are  defined as 50 and it is a public room. For server side extension script I have named it login.

Step 3:  Server side Extension :

For “login.as” I would like to use the example extension given by SmartFoxServer for the server side.So Now our server side extension will look like this

c

dNow Start your server and it will add a new zone “login ”.

e

Step 4: Client Side

Lets create our first screen for establishing connection.

t

In the first layer of Fla I have created the connection status movie clip named connectionStatus_MC where I have taken a dynamic text box statusMsg_txt which will show status of connection with server. On load automatically we will send the connection request to the server.


f

So now we need a login Panel I have created this panel from where user can send login request to the server. There are two input boxes username_txt and pwd_txt for User name and Password. And butt_login to send the request to the server. Also a dynamic text box msg_txt for the message display.

So Now lets Start the Client Side Code.

customLogincustomLoginCode2customLoginCode3customLoginCode4

SmartFoxServer Chapter 12 – server side config –part-9

October 10th, 2010 by admin | 2 Comments | Filed in Server Side Config, SmartFox Server

server side config -part-9

Zone : Specify the combination of rooms and extensions. In other words we can say that the for one application or game generally we define one zone.

Extensions : These are the server side file which we use for the application.

SmartFoxServer Chapter 11 – server side config –part-8

October 10th, 2010 by admin | No Comments | Filed in Server Side Config, SmartFox Server

server side config -part-8

Active : It is a Boolean value. By selecting true/false we can on/off webserver.

CfgFile: It shows the location of http server config file.

SmartFoxServer Chapter 10 – server side config –part-7

October 10th, 2010 by admin | 2 Comments | Filed in Server Side Config, SmartFox Server

AutoReloadExtensions : It is a Boolean value . By using it we can  enable/disable the

auto-reload feature for extensions. For example  the server will reload extensions

as soon as they are modified.

IpFilter :  Here we specify the number of users that
can be created by one single IP Address.
Mailer : Here we can set the email. The required thing is valid SMTP account.

MailHost :  Here we specify the SMTP IP address or host name.

MailUser : Here we specify the SMTP username.

MailPass : Here we specify password.

SmtpPort: Here we specify the SMTP port number.

EnableZoneInfo : It is Boolean value . using feature Enable / disable we can know how many clients are connected through the server currently.