File tree Expand file tree Collapse file tree 1 file changed +17
-10
lines changed
crates/rmcp/src/transport Expand file tree Collapse file tree 1 file changed +17
-10
lines changed Original file line number Diff line number Diff line change @@ -113,16 +113,20 @@ impl<C: SseClient> SseClientTransport<C> {
113
113
config : SseClientConfig ,
114
114
) -> Result < Self , SseTransportError < C :: Error > > {
115
115
let mut sse_stream = client. get_stream ( config. uri . clone ( ) , None , None ) . await ?;
116
- // wait the endpoint event
117
- let endpoint = loop {
118
- let sse = sse_stream
119
- . next ( )
120
- . await
121
- . ok_or ( SseTransportError :: UnexpectedEndOfStream ) ??;
122
- let Some ( "endpoint" ) = sse. event . as_deref ( ) else {
123
- continue ;
124
- } ;
125
- break sse. data . unwrap_or_default ( ) ;
116
+ let endpoint = if let Some ( endpoint) = config. use_endpoint . clone ( ) {
117
+ endpoint
118
+ } else {
119
+ // wait the endpoint event
120
+ loop {
121
+ let sse = sse_stream
122
+ . next ( )
123
+ . await
124
+ . ok_or ( SseTransportError :: UnexpectedEndOfStream ) ??;
125
+ let Some ( "endpoint" ) = sse. event . as_deref ( ) else {
126
+ continue ;
127
+ } ;
128
+ break sse. data . unwrap_or_default ( ) ;
129
+ }
126
130
} ;
127
131
let post_uri: Arc < str > = format ! (
128
132
"{}/{}" ,
@@ -151,13 +155,16 @@ impl<C: SseClient> SseClientTransport<C> {
151
155
pub struct SseClientConfig {
152
156
pub uri : Arc < str > ,
153
157
pub retry_policy : Arc < dyn SseRetryPolicy > ,
158
+ /// if this is settled, the client will use this endpoint to send message and skip get the endpoint event
159
+ pub use_endpoint : Option < String > ,
154
160
}
155
161
156
162
impl Default for SseClientConfig {
157
163
fn default ( ) -> Self {
158
164
Self {
159
165
uri : "" . into ( ) ,
160
166
retry_policy : Arc :: new ( super :: common:: client_side_sse:: FixedInterval :: default ( ) ) ,
167
+ use_endpoint : None ,
161
168
}
162
169
}
163
170
}
You can’t perform that action at this time.
0 commit comments