Bonjour tout le monde :mrgreen:
Alors voila, je code mon bot depuis un petit temps, je finis tout le temps par arrêter par manque de temps et d'envie.
Mais cette fois si (je l'espère) c'est la bonne.
Et j'ai besoin de votre aide, j'arrive à codé mon MITM "sans problème" si ce n'est l'architecture.
J'ai essayé plusieurs architecture, et pour le moment, après 3 ou 4 refonte, une seule me semble propre.
Voici le coeur de celle-ci :
Imports System.Net.Sockets
Imports FriendlyBot.API
Imports FriendlyBot.Engine
Imports FriendlyBot.Engine.Managers
Imports FriendlyBot.GUI
Public Class Manager
Implements IDisposable
#Region "Var & events"
Private WithEvents MainLogs As Logs
Private WithEvents ThemeSelector As ThemeSelector
Private WithEvents PluginLoader As PluginLoader
Private WithEvents DofusConnectionListener As DofusConnectionListener
Private WithEvents DofusInjector As DofusInjector
Private WithEvents DofusRawManager As DofusRawManager
Private WithEvents MainForm As MainForm
Private WithEvents OptionsForm As OptionsForm
Private WithEvents PluginForm As PluginForm
Public Sub New()
MainLogs = New Logs
MainLogs.Add("Logs Initialized", API.LogType.Debug)
ThemeSelector = New ThemeSelector
MainLogs.Add("ThemeSelector Initialized", API.LogType.Debug)
PluginLoader = New PluginLoader
MainLogs.Add("PluginLoader Initialized", API.LogType.Debug)
DofusConnectionListener = New DofusConnectionListener
MainLogs.Add("DofusConnectionListener Initialized", API.LogType.Debug)
DofusInjector = New DofusInjector
MainLogs.Add("DofusInjector Initialized", API.LogType.Debug)
DofusRawManager = New DofusRawManager(DofusInjector) 'faudrais changé ...
MainLogs.Add("DofusRawManager Initialized", API.LogType.Debug)
MainForm = New MainForm(Me)
OptionsForm = New OptionsForm(Me)
PluginForm = New PluginForm(Me)
MainLogs.Add("MainForm, OptionsForm and PluginForm Initialized", API.LogType.Debug)
End Sub
Public Sub Start()
Application.Run(MainForm)
End Sub
Private Sub OnConnectionCompleted(TcpClient As TcpClient) Handles DofusConnectionListener.ConnectionCompleted
If MainForm.InvokeRequired Then
MainForm.Invoke(New Action(Of TcpClient)(AddressOf AddBotManager), TcpClient)
Else
AddBotManager(TcpClient)
End If
End Sub
'Autres, par exemple MainForm.Closing pour Dispose.
#End Region
#Region "ThreadSafe methods"
Private Sub AddBotManager(TcpClient As TcpClient)
Throw New NotImplementedException
'Dim BotManager As New BotManager(Me, TcpClient)
'BotManagerList.add(BotManager)
'BotManager = Manager pour chaque client connecté, il gère donc le transfère Dofus <=> Server, les plugins, ..
End Sub
#End Region
#Region "Public Methods"
Public Sub ShowOptionsForm()
OptionsForm.Show()
End Sub
Public Sub ShowPluginForm()
PluginForm.Show()
End Sub
Public Sub StartDofus()
DofusRawManager.StartDofus()
End Sub
Public Sub SetTheme(ThemeName As String)
ThemeSelector.SetTheme(ThemeName)
End Sub
Public Function GetPluginsAttribute() As PluginAttribute()
Return PluginLoader.GetPluginsAttribute()
End Function
Public Sub LoadPlugin(InstanceID As Integer)
Throw New NotImplementedException
End Sub
Public Sub UnloadPlugin(p1 As Integer)
Throw New NotImplementedException
End Sub
#End Region
#Region "IDisposable Support"
Private disposedValue As Boolean = False
Protected Overridable Sub Dispose(disposing As Boolean)
If Not Me.disposedValue Then
If disposing Then
MainLogs = Nothing
ThemeSelector = Nothing
PluginLoader = Nothing
DofusInjector = Nothing
DofusRawManager = Nothing
End If
DofusConnectionListener.Dispose()
DofusConnectionListener = Nothing
MainForm.Dispose()
MainForm = Nothing
OptionsForm.Dispose()
OptionsForm = Nothing
PluginForm.Dispose()
PluginForm = Nothing
End If
Me.disposedValue = True
End Sub
Protected Overrides Sub Finalize()
Dispose(False)
MyBase.Finalize()
End Sub
Public Sub Dispose() Implements IDisposable.Dispose
Dispose(True)
GC.SuppressFinalize(Me)
End Sub
#End Region
End Class
Voilà, même si le code n'est pas complet, il représente bien l'architecture et j'aimerais savoir votre avis sur cette architecture, voire une autre proposition, avant que je code tout.. Merci.
Ps : je sais que je ne respecte pas certaines norme de nomenclature, mais bon .. vilaines habitudes.