pip_services_sessions 1.1.1 copy "pip_services_sessions: ^1.1.1" to clipboard
pip_services_sessions: ^1.1.1 copied to clipboard

Sessions microservice for Pip.Services in Dart. It opens and closes user sessions and stores session data.

example/README.md

Examples for Sessions Microservice #

This is user sessions microservice from Pip.Services library. It opens and closes user sessions and stores sessiond data.

Define configuration parameters that match the configuration of the microservice's external API

// Service/Client configuration
var httpConfig = ConfigParams.fromTuples(
	"connection.protocol", "http",
	"connection.host", "localhost",
	"connection.port", 8080
);

Instantiate the service

persistence = SessionsMemoryPersistence();
persistence.configure(ConfigParams());

controller = SessionsController();
controller.configure(ConfigParams());

service = SessionsHttpServiceV1();
service.configure(httpConfig);

var references = References.fromTuples([
    Descriptor('pip-services-sessions', 'persistence', 'memory',
        'default', '1.0'),
    persistence,
    Descriptor('pip-services-sessions', 'controller', 'default',
        'default', '1.0'),
    controller,
    Descriptor(
        'pip-services-sessions', 'service', 'http', 'default', '1.0'),
    service
]);

controller.setReferences(references);
service.setReferences(references);

await persistence.open(null);
await service.open(null);

Instantiate the client and open connection to the microservice

// Create the client instance
var client = SessionsHttpClientV1(config);

// Configure the client
client.configure(httpConfig);

// Connect to the microservice
try{
  await client.open(null)
}catch() {
  // Error handling...
}       
// Work with the microservice
// ...

Now the client is ready to perform operations


    // Open new session
    try {
      var session1 = await client.openSession('123', '1', 'User 1', 'localhost', 'test', 'abc');
      // Do something with the returned session...
    } catch(err) {
      // Error handling...     
    }
// Get the session
try {
var session = await client.getSessionById(
    null,
    session1.id);
    // Do something with session...

    } catch(err) { // Error handling}

In the help for each class there is a general example of its use. Also one of the quality sources are the source code for the tests.

0
likes
130
points
2
downloads

Publisher

verified publisherentinco.com

Weekly Downloads

Sessions microservice for Pip.Services in Dart. It opens and closes user sessions and stores session data.

Homepage

Documentation

API reference

License

MIT (license)

Dependencies

http, pip_services3_commons, pip_services3_components, pip_services3_container, pip_services3_data, pip_services3_grpc, pip_services3_mongodb, pip_services3_rpc

More

Packages that depend on pip_services_sessions