-
Notifications
You must be signed in to change notification settings - Fork 451
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature Request] Expose custom transport data streams #838
Comments
Thanks for reaching out @HexaField When a transport connection is initially created we create a We need to take a few things into account though. Libp2p is a modular stack with multiple transports and consequently, transport agnostic. Exposing the raw connection will mean that the underlying API for the raw connection will be different according to the transport being used. This might create issues in the application layer as users will need to take into account these differences in the application layer. Other than that, exposing the raw connection might lead into unexpected behaviours in libp2p, such as if a raw connection is directly closed in the raw connection. Overall, I think that this feature is valuable for several application use cases. Perhaps we can try to find a balance and expose raw connection functions per configuration. A potential way of doing this would be to add to the {
transportFunctions: { }
} In the transport layer, each transport would have a exposeTransportFunctions: (rawConn) => { addStream: rawConn.addStream } With a design like this, the user would be able to expose transport based functions to use in the application layer (if they exist). A simpler approach could be to add a transport string identifier in the I think using the configuration approach would be better as it would be less prone to application layer surprises and less magical. Users might not understand why a given rawConn has the What do you think @HexaField @jacobheun ? |
Thanks for the reply! My thoughts looking through how this works is that a simpler fix might be to add a boolean option to the libp2p config If I do agree that adding transport tags to |
@HexaField sorry for not getting an answer for this yet. I have discussed this synchronously with @jacobheun but he did not get to a decision yet. One problematic aspect of this is that we are multiplexing the connection with libp2p mplex. Once we expose the raw connection and people can use it, this will affect the multiplexer that will attempt to do its thing and affect exchanged messages. We hope to get back to an answer for this soon |
Hello! Interestingly enough I have exactly need :) Using |
Would a potential solution include exposing the raw connection internally, such that libp2p modules can access it and provide functionality that way? My thoughts are to have a |
I think the simplest solution here is to indeed just expose the raw connection. Right now that's hidden in the The other option which we could do later anyway, that would be best done with the configuration proposal, would be to make it easier for developers to provide their own upgrader. This is a lot more work for application developers, but provides a lot of options for customizing what's exposed. |
Closing as this is abstracted away from consumers intentionally, as a work around consumers can cast a WebRTC transport listener as a type with a peer Connection which will give you access to the WebRTC session. |
WebRTC and potentially other transports support media streams (such as video and audio). It would be great to use libp2p directly to expose the relevant hooks/interfaces to enable this functionality, as opposed to opening a second connection and reimplementing a lot of what simple-peer / libp2p-webrtc-peer and libp2p-webrtc-star do.
The requirements I can identity thus far are only to add a way to (dynamically pass a stream)[https://github.com/ipfs-shipyard/simple-peer#dynamic-videovoice] via the
peer.addStream
function and add an event hook for thepeer.on("stream")
event.The text was updated successfully, but these errors were encountered: