This repository has been archived by the owner on Mar 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
82c7398
commit aebc3b5
Showing
10 changed files
with
93 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/main/java/fr/atlasworld/network/core/networking/handler/SocketInitializer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package fr.atlasworld.network.core.networking.handler; | ||
|
||
import fr.atlasworld.network.api.security.SecurityManager; | ||
import fr.atlasworld.network.api.services.database.Database; | ||
import fr.atlasworld.network.api.services.database.DatabaseService; | ||
import fr.atlasworld.network.core.networking.codec.ApiConverterCodec; | ||
import fr.atlasworld.network.core.networking.codec.NetworkCodec; | ||
import fr.atlasworld.network.core.networking.security.authentication.AuthenticationProfile; | ||
import fr.atlasworld.network.core.networking.security.encryption.EncryptionManager; | ||
import fr.atlasworld.network.core.networking.security.encryption.SystemEncryptionManager; | ||
import io.netty.channel.ChannelInitializer; | ||
import io.netty.channel.socket.SocketChannel; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class SocketInitializer extends ChannelInitializer<SocketChannel> { | ||
private final DatabaseService databaseService; | ||
private final SecurityManager securityManager; | ||
|
||
public SocketInitializer(DatabaseService databaseService, SecurityManager securityManager) { | ||
this.databaseService = databaseService; | ||
this.securityManager = securityManager; | ||
} | ||
|
||
@Override | ||
protected void initChannel(@NotNull SocketChannel ch) throws Exception { | ||
Database<AuthenticationProfile> database = this.databaseService.getDatabase("auth", new AuthenticationProfile.AuthenticationProfileFactory()); | ||
EncryptionManager encryptionManager = new SystemEncryptionManager(this.securityManager); | ||
|
||
NetworkCodec codec = new ApiConverterCodec(); | ||
|
||
ch.pipeline() | ||
//Out | ||
.addLast(new DecodeHandler(database, encryptionManager, codec)) | ||
.addLast(new ResourceHandler()) | ||
|
||
//In | ||
.addLast(new EncodeHandler(encryptionManager, codec)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters