|
-
Feb 13th, 2009, 07:50 PM
#1
Thread Starter
Fanatic Member
plug-ins?
i know how to create plug-ins but I wan't my server & client to be almost completely based upon Plug-Ins, my problem is my Main program proccesses all packets like this:
Code:
Private Sub ProcessMessagesFrom(ByVal index As Integer)
Dim lngDelimiter As Long
Dim data As String
Dim lngWsk As Long
'Search for whole messages, extract them, and process them.
Do
lngDelimiter = InStr(strBuffer(index), MESSAGE_DELIMITER)
If lngDelimiter > 0 Then
'Found a whole message. Extract it.
data = Left$(strBuffer(index), lngDelimiter)
strBuffer(index) = Mid$(strBuffer(index), lngDelimiter + 1)
If User(index).ClientUpToDate = True Then
If Left(data, 3) = "REG" Then ' registering
data = Left(data, Len(data) - Len(MESSAGE_DELIMITER))
data = Right(data, Len(data) - 3)
Call DoRegister(data, index)
ElseIf Left(data, 5) = "LOGIN" Then ' registering
data = Left(data, Len(data) - Len(MESSAGE_DELIMITER))
data = Right(data, Len(data) - 5)
Call AccountLogIn(index, data)
End If
Else 'client not up to date. check
If Left(data, 3) = "VER" Then
data = Left(data, Len(data) - Len(MESSAGE_DELIMITER))
If Version1 <> Right(data, Len(data) - 3) Then
Winsock1(index).SendData "VERNOhttp://www.teampo2.com/OnlineCrimeMMORPGClient.zip" & MESSAGE_DELIMITER
DoEvents
Else
User(index).ClientUpToDate = True
End If
End If
End If
End If
Loop Until lngDelimiter < 1
Exit Sub
End Sub
What I need is to somehow have my plug-ins be able to be put into the processMessagesFrom somehow? is it possible, if so how so?
-
Feb 15th, 2009, 04:54 AM
#2
Re: plug-ins?
Theoreticaly, a plugin have an "input" and an "output" pairs, that is helps you to transfer data between host and plugin. Your application is the host. Just to make things clear
So, you can create an activeX dll, that is you can declare in your application, then in the processMessagesFrom() method, you can send out the same data to each plugins, then receive the results one by one.
Create a Send() subroutine and Receive() function in your activex dll "plugin".
Code:
'The code will send out the same message to each plugins
Dim i As Long
For i = 1 to Ubound(myPlugin)
Call myPlugin(i).Send(ThisIsMyData$)
Next i
'....
'Now you can receive the results
ReDim MyPluginResult(Ubound(myPlugin)) as String
For i = 1 to Ubound(myPlugin)
MyPluginResult(i) = myPlugin(i).Receive
Next i
Or, you can "Chain" the plugins, to process the data in a sequential order.
Code:
Dim i As Long
For i = 1 to Ubound(myPlugin)
ThisIsMyData$ = myPlugin(i).SendRecv(ThisIsMyData$)
Next i
The later, will send out the content of ThisIsMyData, to the SendRecv function, that is immediately sends back the modified/processed data. The received data will be the new content that is will be sent to the next plugin. And so on.
Is this clear?
-
Feb 16th, 2009, 02:13 AM
#3
Thread Starter
Fanatic Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|