-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #39 from rsocket/bugfix/channel
bugfix for REQUEST_CHANNEL.
- Loading branch information
Showing
15 changed files
with
289 additions
and
172 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"github.com/rsocket/rsocket-go" | ||
"github.com/rsocket/rsocket-go/logger" | ||
"github.com/rsocket/rsocket-go/payload" | ||
"github.com/rsocket/rsocket-go/rx" | ||
"github.com/rsocket/rsocket-go/rx/flux" | ||
) | ||
|
||
var testData = "Hello World!" | ||
|
||
func main() { | ||
logger.SetLevel(logger.LevelDebug) | ||
err := rsocket.Receive(). | ||
Fragment(128). | ||
Acceptor(func(setup payload.SetupPayload, sendingSocket rsocket.CloseableRSocket) rsocket.RSocket { | ||
return rsocket.NewAbstractSocket( | ||
rsocket.RequestChannel(func(inputs rx.Publisher) flux.Flux { | ||
//var count int32 | ||
//countPointer := &count | ||
receives := make(chan payload.Payload) | ||
|
||
go func() { | ||
var count int32 | ||
for range receives { | ||
count++ | ||
} | ||
fmt.Println("***** count:", count) | ||
}() | ||
|
||
inputs.(flux.Flux).DoFinally(func(s rx.SignalType) { | ||
close(receives) | ||
}).Subscribe(context.Background(), rx.OnNext(func(input payload.Payload) { | ||
//fmt.Println("rcv from channel:", input) | ||
receives <- input | ||
})) | ||
|
||
return flux.Create(func(ctx context.Context, s flux.Sink) { | ||
for i := 0; i < 2; i++ { | ||
s.Next(payload.NewString(testData, fmt.Sprintf("%d_from_server", i))) | ||
} | ||
s.Complete() | ||
}) | ||
}), | ||
) | ||
}). | ||
Transport("tcp://127.0.0.1:7878"). | ||
Serve(context.Background()) | ||
fmt.Println("SERVER STOPPED!!!!!") | ||
panic(err) | ||
} |
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
Oops, something went wrong.