コード例 #1
0
func (this *Session) Serve() {
	this.pipeline = packet.NewPacketPipeline()
	this.pipeline.AddLast("varIntLength", packet.NewPacketCodecVarIntLength())
	this.pipeline.AddLast("registry", minecraft.HandshakePacketServerCodec)
	this.connCodec = packet.NewPacketConnCodec(this.conn, this.pipeline, 30*time.Second)
	this.connCodec.ReadConn(this)
}
コード例 #2
0
ファイル: session.go プロジェクト: 0xNiklas/GoLilyPad
func (this *Session) Serve() {
	this.pipeline = packet.NewPacketPipeline()
	this.pipeline.AddLast("varIntLength", packet.NewPacketCodecVarIntLength())
	this.pipeline.AddLast("registry", connect.PacketCodec)
	this.connCodec = packet.NewPacketConnCodec(this.conn, this.pipeline, 10*time.Second)
	this.connCodec.ReadConn(this)
}
コード例 #3
0
func (this *SessionOutBridge) Serve() {
	this.pipeline = packet.NewPacketPipeline()
	this.pipeline.AddLast("varIntLength", packet.NewPacketCodecVarIntLength())
	this.pipeline.AddLast("registry", minecraft.HandshakePacketClientCodec)
	this.connCodec = packet.NewPacketConnCodec(this.conn, this.pipeline, 30*time.Second)

	inRemotePort, _ := strconv.ParseUint(this.session.remotePort, 10, 16)
	outRemotePort, _ := strconv.ParseUint(this.remotePort, 10, 16)
	loginPayload := LoginPayload{
		SecurityKey: this.server.SecurityKey,
		Host:        this.session.serverAddress,
		RealIp:      this.session.remoteIp,
		RealPort:    int(inRemotePort),
		Name:        this.session.name,
		UUID:        this.session.profile.Id,
		Properties:  make([]LoginPayloadProperty, 0),
	}
	for _, property := range this.session.profile.Properties {
		loginPayload.Properties = append(loginPayload.Properties, LoginPayloadProperty{property.Name, property.Value, property.Signature})
	}
	this.Write(minecraft.NewPacketServerHandshake(this.session.protocolVersion, EncodeLoginPayload(loginPayload), uint16(outRemotePort), 2))

	if this.session.protocol17 {
		this.pipeline.Replace("registry", minecraft.LoginPacketClientCodec17)
	} else {
		this.pipeline.Replace("registry", minecraft.LoginPacketClientCodec)
	}
	this.Write(minecraft.NewPacketServerLoginStart(this.session.name))

	this.state = STATE_LOGIN
	go this.connCodec.ReadConn(this)
}
コード例 #4
0
func (this *ConnectImpl) Connect(addr string) (err error) {
	this.Disconnect()
	this.conn, err = net.Dial("tcp", addr)
	if err != nil {
		return
	}
	this.recordsMutex.Lock()
	defer this.recordsMutex.Unlock()
	this.records = make(map[int32]*RequestRecord)
	this.pipeline = packet.NewPacketPipeline()
	this.pipeline.AddLast("varIntLength", packet.NewPacketCodecVarIntLength())
	this.pipeline.AddLast("registry", NewCodecRegistry(this))
	this.connCodec = packet.NewPacketConnCodec(this.conn, this.pipeline, 10*time.Second)
	go this.connCodec.ReadConn(this)
	return
}