Hyderabad Jobs Book Website FREE PowerBuilder Training I Love Hyderabad Hyderabad Colleges
Home Business Emails Hyderabad Classifieds Contact Us
7 Wonders of Hyderabad Web Hosting Yellow Pages Our Network

 
Webpowerbuilder.hyderabad-colleges.com

Mastering PowerBuilder

HomePrevious Lesson: Saving and Loading Server Options
Next Lesson: Monitoring Connection Information From the Server Console

Starting/Stopping DPB Server

// Object: cb_start_or_stop_server in w_pms_server
// Event: Clicked
Long ll_rc, ll_row
String ls_Temp
Integer li_return
dw_users.Reset()
IF This.Text = '&Start Server' THEN
   of_SetTransportObjectValues()
   // Start listening for client connections.
   ll_rc = gtrp_transport.Listen()
   If ll_rc != 0 OR gtrp_transport.ErrCode != 0 Then
      MessageBox( "Error", gtrp_Transport.ErrText, StopSign!,OK!,1 )
      Retun -1
   END IF
   cb_start_or_stop_server.text = "&Stop Server"
   cb_refresh.Enabled = TRUE
   cb_exit.Enabled = FALSE
   Timer(60)
ELSE
   Parent.of_disconnect("ALL")
   ll_rc = gtrp_transport.StopListening()
   IF li_return = 0 THEN
      cb_start_or_stop_server.text = "&Start Server"
      cb_refresh.Enabled = FALSE
      cb_exit.Enabled = TRUE
   END IF
   Timer(0)
END IF
Return

In the above script, we are starting and stopping the server depending on the text displayed on the CommandButton. If it is 'Start Server' then we are starting the server and changing the text to 'Stop Server' and vice-versa. After this function call, we are calling Listen() function to make the server to listen to clients.

Once the server starts, we are calling Timer() function to fire the timer event every 60 seconds to bring the connected users information and to refresh the screen. Timer event script is explained in a moment. To make the server to stop listening to the clients, we are calling StopListening() function at the transport object and enabling/disabling appropriate CommandButtons.

The following code is written for cb_server_options CommandButton's clicked event toggles the CommandButton's text between Console, Server Options and Save Options and takes action depending on the text of that CommandButton.
// Event: Clicked
// Object: cb_server_options CommandButton
// in w_pms_server window
If This.Text = 'Server &Options' Then
   dw_options.Show()
   dw_users.Hide()
   This.Text = '&Console'
   cb_refresh.Enabled = False
ElseIf This.Text = '&Console' Then
   dw_users.Show()
   dw_options.Hide()
   This.Text = 'Server &Options'
  	IF cb_start_or_stop_server.text = '&Stop Server' THEN
      cb_refresh.Enabled = True
  	END IF
ElseIf This.Text = 'Save &Options' Then
   Parent.of_SaveServerOptions()
   This.Text = '&Console'
End If

We need to change the CommandButton's text to 'Save Options' from the dw_options's ItemChanged event.
// Event: ItemChanged
// Object: dw_options in w_pms_server window
cb_server_options.Text = 'Save &Options'
HomePrevious Lesson: Saving and Loading Server Options
Next Lesson: Monitoring Connection Information From the Server Console

Copyright © 1996 - 2006 HamaraShehar.com Pvt. Ltd. All Rights Reserved.
Domain Registration, Website Design, Website Hosting by HamaraShehar.com