source_server 1.0.6

SourceSerer #

A library to connect to Source Dedicated Servers [CS:GO, CSS, TF2, ...]

Get started #

Import the library (make sure to check for the latest version).

depedencies:
    source_server: ^1.0.0

And call the SourceServer constructor.

It contains both RconServer and QueryServer instances, if you wish to use just one protocol you can still use one of those classes.

// The SourceServer constructor requires an InternetAddress and a port, if you wish to
// use the rcon connection as well you need to provide a password as well.
var server = SourceServer((await InternetAddress.lookup('hexah.net')).first, 27015);

The only required parameter is the first, password, the ip and port by default are: localhost:27015

To establish a connection to the server call the connect method. It will return a Future<void> that will be completed when the connection to the server is successfully established.

await server.connect();

Sending commands to the RCON #

Use

var reply = await server.send('status');

the method command will return a Future<String> what will return the command reply.

the SourceServer provides also a way to parse the status command.

var status = wait server.getStatus();

Example reply:

{
	server: 
	{   
		hostname: Server name, 
		version: 1.36.8.2/13682 886/7424 secure  [G:1:xxxxxxx], 
		udp/ip: xxx.xx.xxx.xx:27015  (public ip: xxx.xx.xxx.xx), 
		os: Linux, 
		type: community dedicated, 
		map: de_mirage, 
		players: 0 humans, 0 bots (16/0 max) (not hibernating)
	}, 
	//If the server is not empty it will return a list containing all the players in the server (and it's info)
	players: []
}

Sending commands using the query protocol #

Look in the API documentation for all the available methods, here is an example:

var info = server.getInfo();

Returns a Future<Map> holding all the (parsed) server info.

TODO #

Check the issues page on github

1.0.0 #

  • Initial version, created by Stagehand

example/example.dart

import 'dart:io';

import 'package:source_server/source_server.dart';

Future<void> main() async {
  var query = SourceServer(InternetAddress('127.0.0.1'), 27015, 'mypassword');
  await query.connect();
  print(await query.getStatus());
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  source_server: ^1.0.6

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:source_server/source_server.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
29
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
98
Overall:
Weighted score of the above. [more]
64
Learn more about scoring.

We analyzed this package on Jul 17, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.4.0
  • pana: 0.12.19

Platforms

Detected platforms: Flutter, other

Primary library: package:source_server/source_server.dart with components: io.

Maintenance suggestions

The package description is too short. (-2 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
logging ^0.11.3+2 0.11.3+2
pedantic ^1.5.0 1.8.0+1

Admin