hlx's Profile
Reputation: 31
Craftsman
- Group:
- Contributors
- Active Posts:
- 133 (0.14 per day)
- Joined:
- 13-November 10
- Profile Views:
- 2,436
- Last Active:
Apr 14 2013 07:05 AM- Currently:
- Offline
Previous Fields
- Country:
- CA
- OS Preference:
- Windows
- Favorite Browser:
- FireFox
- Favorite Processor:
- AMD
- Favorite Gaming Platform:
- Nintendo
- Your Car:
- Chevrolet
- Dream Kudos:
- 25
Posts I've Made
-
In Topic: Data Storage for a MUD server
Posted 22 Mar 2012
Simown, on 22 March 2012 - 10:32 AM, said:I think flat file is a no-no, depending you want to store anything over a handful of data, a relational database would make processing and queries on this data much easier in the long run. If you were just storing it as a .txt file or something, the security may be at risk.
You say using SQLite which lends itself to be a local database, but wouldn't the users need to connect to validate their accounts and get user data?
I'd go for something like MySQL or PostgreSQL as a DBMS, only if is to make your job easier.
They do need to validate, but it will be through the telnet server as it is a MUD. so the server will take their input, and look it up in the DB. Multiple users will not be connecting directly to the database.
I may just use MySQL as above and be done with it. -
In Topic: Understanding a Simple Asynchronous Telnet Server
Posted 22 Mar 2012
if it helps, here is code for a MUD server that I am working on, that baavgai had helped me out with.
from miniboa import TelnetServer import os, os.path # because globals suck # classes to come # IDLE_TIMEOUT = 5000 # CLIENT_LIST = [] # SERVER_RUN = True # this is our client base # we'll hold the telent client and do all the work here class MudClientBase(object): def __init__(self, telnetClient, idle_timeout): self.telnetClient = telnetClient self.idle_timeout = idle_timeout def logout(self): # self.telnetClient.active = False self.telnetClient.deactivate() self.telnetClient = None # this is neat, ever time we check for active # we have a chance to invalidate them if they're not def isActive(self): if self.telnetClient: if self.telnetClient.active: if self.telnetClient.idle() > self.idle_timeout: print("-- Kicking idle client from {}".format(self.getName())) self.logout() else: return True return False # name is more useful # once they're logged in, we can give them a real name def getName(self): if self.isActive(): return self.telnetClient.addrport() return None # wrapping telnetClient commands gives us complete control def hasCommand(self): return self.isActive() and self.telnetClient.cmd_ready def getCommand(self): if self.isActive(): return self.telnetClient.get_command().lower().strip() return None def send(self, msg): if self.isActive(): self.telnetClient.send(msg + '\n') def send_cc(self, text): if self.isActive(): self.telnetClient.send_cc(text) # this is a basic wrapper for a server class MudServerBase(object): def __init__(self, idle_timeout): self.idle_timeout = idle_timeout self.clients = [] self.running = False self.port = 7777 self.address = '' self.timeout = 0.05 # wrap the raw TelnetClient def addClient(self, client): client = MudClientBase(client, self.idle_timeout) self.clients.append(client) return client def showWelcome(self, client): client.send('Howdy stranger!') def onConnect(self, client): client = self.addClient(client) print("++ Opened connection to {}".format(client.getName())) self.showWelcome(client) def removeClient(self, client): if client in self.clients: if client.isActive(): client.logout() print("-- Removed Client {}".format(client.getName())) self.clients.remove(client) def onDisconnect(self, client): print("-- Lost connection to {}".format(client.addrport())) found = [ c for c in self.clients if c.telnetClient==client ] if not found==[]: self.removeClient(found[0]) def broadcast(self, msg): for client in self.clients: client.send(msg) def getTelnetServer(self): return TelnetServer( port=self.port, address=self.address, on_connect=self.onConnect, on_disconnect=self.onDisconnect, timeout=self.timeout ) def processClient(self, client): print("{} entered {}".format(client.getName(), client.getCommand())) def start(self): telnet_server = self.getTelnetServer() print("\n>> Listening for connections on port {}. CTRL-C to break.\n".format(telnet_server.port)) self.running = True while self.running: telnet_server.poll() # print telnet_server.clients for client in self.clients: if client.hasCommand(): self.processClient(client) print(">> Server shutdown.") # now the magic happens # time for code specfic to our game # this is our client # with extra info goodness class MudClient(MudClientBase): def __init__(self, telnetClient, idle_timeout): MudClientBase.__init__(self, telnetClient, idle_timeout) self.resetState() def resetState(self): # I'm not sure about the numeric state # however, for login it makes sense self.GAME_STATE = 0 # your OMG huge list of variables # note, player_* is kind of redundant # I don't have the heart to change it at the moment self.player_name = None # this is a Python null, very handy self.player_creationstate = 0 self.player_hp = 0 self.player_mp = 0 self.player_exp = 0 self.player_exptolevel = 0 self.player_level = 0 self.player_str = 0 self.player_vit = 0 self.player_dex = 0 self.player_mys = 0 self.player_inventory = [] self.player_gold = 0 self.player_armor = 0 self.player_weapon = 0 self.player_attack = 0 self.player_defense = 0 self.player_magicattack = 0 self.player_race = 0 self.player_class = 0 self.player_skills = [] self.player_region = 0 self.player_jailed = 0 self.player_banned = 0 self.player_warninglvl = 0 self.player_guild = 0 def getName(self): if self.player_name: return self.player_name else: return MudClientBase.getName(self) def setName(self, name): self.player_name = name # this our server class MudServer(MudServerBase): # States: Login, New, NonNew, Play, Dead, Jailed (STATE_LOGIN, STATE_NEW, STATE_WAITING_NEW, STATE_LOGIN_DONE) = range(4) def __init__(self, idle_timeout): MudServerBase.__init__(self, idle_timeout) self.gameName = "Faded Reality" # time for our custome client def addClient(self, client): client = MudClient(client, self.idle_timeout) self.clients.append(client) return client def showWelcome(self, client): msg = "^WWelcome to ^R" + self.gameName + "^~" + "^W! This will be an ascii logo eventually\n\n" msg += "^~(Press any key to continue.)\n\n" client.send_cc(msg) def getFilenameForPlayer(self, name): return "data/player_{}.plr".format(name) def playerExists(self, name): return os.path.exists(self.getFilenameForPlayer(name)) def loadPlayer(self, client): pass def savePlayer(self, client): pass def processLogin(self, client, cmd): def showNewMessage(): client.send_cc('^WPlease enter your player name or type ^~"^Gnew^~" ^Wto create one:^~\n') client.send("> ") def showNamePrompt(): client.send_cc("\n^WBy what name do you wish to be called?^G:^~ ") def welcomePlayer(): client.GAME_STATE = MudServer.STATE_LOGIN_DONE client.send("Welcome " + client.getName() + ". What do you want to do?") if client.GAME_STATE==MudServer.STATE_LOGIN: showNewMessage() client.GAME_STATE = MudServer.STATE_NEW elif client.GAME_STATE==MudServer.STATE_NEW: if cmd=='': showNewMessage() elif cmd=='new': showNamePrompt() client.GAME_STATE = MudServer.STATE_WAITING_NEW elif self.playerExists(cmd): client.setName(cmd) self.loadPlayer(client) welcomePlayer() else: client.send("There is no player by that name.") elif client.GAME_STATE==MudServer.STATE_WAITING_NEW: if cmd=='': showNamePrompt() elif self.playerExists(cmd): client.send_cc("\n^WERROR^W: ^RThat user already exists! Try again!^~\n") showNamePrompt() else: client.setName(cmd) self.savePlayer(client) welcomePlayer() else: return False return True # this is the "state" code def processClient(self, client): cmd = client.getCommand() if self.processLogin(client, cmd): if client.GAME_STATE == MudServer.STATE_LOGIN_DONE: print("Login {}".format(client.getName())) elif cmd=='bye': self.removeClient(client) else: client.send("Sorry {}, I don't know how to '{}'.".format(client.getName(), cmd)) if __name__ == '__main__': server = MudServer(5000) server.start() -
In Topic: Microsoft Fax Error Monitoring (SBS2008)
Posted 8 Sep 2011
I would hawk, but I'm compiling on a machine that is not the server. I do not have licenses for the server. -
In Topic: Microsoft Fax Error Monitoring (SBS2008)
Posted 8 Sep 2011
I have a working solution, that is now reporting events (thanks to help resources around the internet)
NOTE: This has to be resident on the server. It will not remotely pull events.
'Visual Basic 2008 - .net 3.5 - Any CPU Imports FAXCOMEXLib Public Class Form1 Private WithEvents pFaxSrv As FaxServer Private StatusBox As TextBox Private ServerNameBox As TextBox Private ServerLabel As Label Private ConnectButton As Button Dim JOBID As String = Nothing Private Sub ConnectButtonclicked(ByVal sender As System.Object, ByVal e As System.EventArgs) If ServerNameBox.Text.Length > 0 Then pFaxSrv = New FaxServer Try pFaxSrv.Connect(ServerNameBox.Text) StatusBox.AppendText("Connected to Server: " + ServerNameBox.Text() + vbCrLf) Catch ex As Exception MsgBox(ex.Message) Exit Sub End Try pFaxSrv.ListenToServerEvents(FAX_SERVER_EVENTS_TYPE_ENUM.fsetDEVICE_STATUS Or FAX_SERVER_EVENTS_TYPE_ENUM.fsetFXSSVC_ENDED Or FAX_SERVER_EVENTS_TYPE_ENUM.fsetOUT_QUEUE) AddHandler pFaxSrv.OnDeviceStatusChange, AddressOf pFaxSrv_OnDeviceStatusChange AddHandler pFaxSrv.OnServerShutDown, AddressOf pFaxSrv_OnServerShutDown AddHandler pFaxSrv.OnOutgoingJobAdded, AddressOf pFaxSrv_OnOutgoingJobAdded AddHandler pFaxSrv.OnOutgoingJobChanged, AddressOf pFaxSrv_OnOutgoingJobChanged Else MsgBox("You need to provide the name of the computer which is running the fax service", MsgBoxStyle.Critical) End If End Sub Private Sub pFaxSrv_OnDeviceStatusChange(ByVal pFaxServer As FAXCOMEXLib.FaxServer, ByVal lDeviceId As Integer, ByVal bPoweredOff As Boolean, ByVal bSending As Boolean, ByVal bReceiving As Boolean, ByVal bRinging As Boolean) Static MyDeviceID As Integer = -1 Dim Value As String = String.Empty If bReceiving Or bRinging Or bPoweredOff Then Value = "Rec:" & bReceiving.ToString & " - " & "Ring:" & bRinging.ToString & " - " & "Pow:" & bPoweredOff.ToString End If If (MyDeviceID <> lDeviceId) Then If (bReceiving Or bRinging Or bPoweredOff) Then Value &= " - " End If Value &= "Dev:" & lDeviceId.ToString MyDeviceID = lDeviceId End If StatusBox.AppendText(Value & vbCrLf) End Sub Private Sub pFaxSrv_OnServerShutDown(ByVal pFaxServer As FAXCOMEXLib.IFaxServer) StatusBox.AppendText("The FAX Service has been stopped." & vbCrLf) End Sub Private Sub pFaxSrv_OnOutgoingJobAdded(ByVal pFaxServer As FAXCOMEXLib.IFaxServer, _ ByVal bstrJobId As String) StatusBox.AppendText("New job added to queue with ID: " + bstrJobId & vbCrLf) JOBID = bstrJobId End Sub Private Sub pFaxSrv_OnOutgoingJobChanged(ByVal pFaxServer As FAXCOMEXLib.IFaxServer, _ ByVal bstrJobId As String, ByVal pJobStatus As FAXCOMEXLib.IFaxJobStatus) 'This event receives the FaxJobStatus object 'Since this event is likely to result in errors, such as trying to 'report the transmission end time before the transmission has ended, 'this subroutine includes error handling 'Error handling On Error GoTo Error_Handler 'Display the FaxJobStatus object's properties when the event is called 'StatusBox.AppendText(pJobStatus.AvailableOperations & _ 'vbCrLf & "Caller ID: " & pJobStatus.CallerId & _ 'vbCrLf & "CSID: " & pJobStatus.CSID & _ 'vbCrLf & "Current page: " & pJobStatus.CurrentPage & _ 'vbCrLf & "Device ID: " & pJobStatus.DeviceId & _ 'vbCrLf & "Extended status: " & pJobStatus.ExtendedStatus & _ 'vbCrLf & "Extended status code: " & pJobStatus.ExtendedStatusCode & _ 'vbCrLf & "Job type: " & pJobStatus.JobType & _ 'vbCrLf & "Pages: " & pJobStatus.Pages & _ 'vbCrLf & "Retries: " & pJobStatus.Retries & _ 'vbCrLf & "Routing information: " & pJobStatus.RoutingInformation & _ 'vbCrLf & "Scheduled time: " & pJobStatus.ScheduledTime & _ 'vbCrLf & "Size: " & pJobStatus.Size & _ 'vbCrLf & "Status: " & pJobStatus.Status & _ 'vbCrLf & "Transmission start: " & pJobStatus.Transmissionstart & _ 'vbCrLf & "TSID: " & pJobStatus.TSID & vbCrLf) MsgBox(pJobStatus.ExtendedStatusCode.ToString()) If pJobStatus.ExtendedStatusCode.ToString() = "fjesBUSY" Then If pJobStatus.Status.ToString() = "fjsRETRIES_EXCEEDED" Then StatusBox.AppendText(vbCrLf & "Job ID " + bstrJobId + " has exceeded the max amount of retries.") 'TODO: Call to fax FAILED email function here. Exit Sub End If StatusBox.AppendText(vbCrLf + "Job ID: " + bstrJobId + " has encountered a BUSY signal. Attempting retry...") End If Exit Sub Error_Handler: 'Implement error handling at the end of your subroutine. This 'implementation is for demonstration purposes StatusBox.AppendText("Error number: " & Hex(Err.Number) & ", " & Err.Description & vbCrLf) End Sub Public Sub New() InitializeComponent() AddControls() End Sub Private Sub AddControls() StatusBox = New TextBox StatusBox.Multiline = True StatusBox.ScrollBars = ScrollBars.Both StatusBox.Location = New Point(12, 51) StatusBox.Size = New Size(258, 103) Me.Controls.Add(StatusBox) ServerNameBox = New TextBox ServerNameBox.Location = New Point(50, 21) ServerNameBox.Size = New Size(152, 20) Me.Controls.Add(ServerNameBox) ServerLabel = New Label ServerLabel.Location = New Point(12, 25) ServerLabel.Text = "Server" Me.Controls.Add(ServerLabel) ConnectButton = New Button ConnectButton.Location = New Point(212, 12) ConnectButton.Size = New Size(58, 33) ConnectButton.Text = "Connect" Me.Controls.Add(ConnectButton) Me.Height = 200 Me.Width = 290 AddHandler ConnectButton.Click, AddressOf ConnectButtonclicked End Sub Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing RemoveHandler ConnectButton.Click, AddressOf ConnectButtonclicked If pFaxSrv IsNot Nothing Then RemoveHandler pFaxSrv.OnDeviceStatusChange, AddressOf pFaxSrv_OnDeviceStatusChange RemoveHandler pFaxSrv.OnServerShutDown, AddressOf pFaxSrv_OnServerShutDown RemoveHandler pFaxSrv.OnOutgoingJobAdded, AddressOf pFaxSrv_OnOutgoingJobAdded RemoveHandler pFaxSrv.OnOutgoingJobChanged, AddressOf pFaxSrv_OnOutgoingJobChanged pFaxSrv.Disconnect() End If End Sub End Class
for some reason, fjesBUSY is getting thrown twice each time the event is called. Why is this? -
In Topic: Open multiple IE windows at once
Posted 7 Sep 2011
This is unable to be done. It will always open in new instances of IE. You could try a webbrowser control, but even they have limitations with tabs.
EDIT: Er, I read that wrong. Anyhow, it's a user preference that cannot be influenced by code. If clicking on a hyperlink opens a new tab, I believe, the same action will always follow suit with VB.NET interaction with IE.
My Information
- Member Title:
- D.I.C Head
- Age:
- 26 years old
- Birthday:
- May 1, 1987
- Gender:
-
- Location:
- Dauphin, MB, Canada
- Interests:
- Programming, VB.net mostly.
- Full Name:
- Justin Tokarchuk
- Years Programming:
- 3
- Programming Languages:
- VB.net, Python, C++
Contact Information
- E-mail:
- Click here to e-mail me
|
|


Find Topics
Find Posts
View Reputation Given



|
Comments
no2pencil
02 Aug 2011 - 20:04hlx
20 Jul 2011 - 08:36y2161994
20 Jul 2011 - 04:16