-behaviour(ssh_server_channel). (Replaces ssh_daemon_channel)
Note!
This module replaces ssh_daemon_channel.
The old module is still available for compatibility, but should not be used for new programs. The old module will not be maintained except for some error corrections
SSH services (clients and servers) are implemented as channels
that are multiplexed over an SSH connection and communicates over
the ssh
applications supervisor tree.
Note!
When implementing a client subsystem handler, use -behaviour(ssh_client_channel) instead.
Callback Functions
The following functions are to be exported from a
ssh_server_channel
callback module.
Functions
Args = term()
State = term()
Reason = term()
start_link/4
.Makes necessary initializations and returns the initial channel state if the initializations succeed.
The time-out values that can be returned
have the same semantics as in a gen_server.
If the time-out occurs, handle_msg/2
is called as handle_msg(timeout, State)
.
Msg = timeout | term()
ChannelId = ssh:channel_id()
State = term()
Handles other messages than SSH Connection Protocol, call, or cast messages sent to the channel.
Possible Erlang 'EXIT' messages is to be handled by this function and all channels are to handle the following message.
{ssh_channel_up, ssh:channel_id(), ssh:connection_ref()}
This is the first message that the channel receives.
This is especially useful if the
server wants to send a message to the client without first
receiving a message from it. If the message is not
useful for your particular scenario, ignore it by
immediately returning {ok, State}
.
Msg = ssh_connection:event()
ChannelId = ssh:channel_id()
State = term()
Handles SSH Connection Protocol messages that may need service-specific attention. For details, see ssh_connection:event().
The following message is taken care of by the
ssh_server_channel
behavior.
{closed, ssh:channel_id()}
The channel behavior sends a close message to the
other side, if such a message has not already been sent.
Then it terminates the channel with reason normal
.
Reason = term()
State = term()
This function is called by a channel process when it is
about to terminate. Before this function is called, ssh_connection:close/2
is called, if it has not been called earlier.
This function does any necessary cleaning
up. When it returns, the channel process terminates with
reason Reason
. The return value is ignored.