Skip to content

Commit

Permalink
Merge git://github.com/94m3k1n9/SteamBot into update-merge
Browse files Browse the repository at this point in the history
Conflicts:
	SteamBot/Bot.cs
  • Loading branch information
teliosdev committed Oct 25, 2012
2 parents 0d706e3 + 65a117f commit 09c845e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 26 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -42,6 +42,6 @@ Accepts the trade.
ends a message to the other user over trade chat.

## More help? ##
If it's a bug, open an Issue; if you have a fix, open a Pull Request. If you have questions or comments, contact <http://steamcommunity.com/jessecar>.
If it's a bug, open an Issue; if you have a fix, open a Pull Request. If you have questions or comments, contact <http://steamcommunity.com/id/jessecar>.

SteamBot is licensed under the MIT license. Check out LICENSE for more details.
48 changes: 23 additions & 25 deletions SteamBot/Bot.cs
Expand Up @@ -53,33 +53,31 @@ public Bot(Configuration.BotInfo config, string apiKey, bool debug = false)

SteamClient.Connect();

while (true)
{
Update();
}
}

public void Update ()
{
while (true) {
CallbackMsg msg = SteamClient.GetCallback (true);

if (msg == null)
break;

HandleSteamMessage (msg);
}

Thread CallbackThread = new Thread(() => // Callback Handling
{
while (true) {
CallbackMsg msg = SteamClient.WaitForCallback (true);
HandleSteamMessage (msg);
}
});

if (CurrentTrade != null) {
Thread.Sleep (800);
try {
CurrentTrade.Poll ();
} catch (Exception e) {
Console.Write ("Error polling the trade: ");
Console.WriteLine (e);
new Thread(() => // Trade Polling if needed
{
while (true) {
Thread.Sleep (800);
if (CurrentTrade != null) {
try {
CurrentTrade.Poll ();
} catch (Exception e) {
Console.Write ("Error polling the trade: ");
Console.WriteLine (e);
}
}
}
}
}).Start ();

CallbackThread.Start();
CallbackThread.Join();
}

void HandleSteamMessage (CallbackMsg msg)
Expand Down

0 comments on commit 09c845e

Please sign in to comment.