Official Everybody Edits Forums

Do you think I could just leave this part blank and it'd be okay? We're just going to replace the whole thing with a header image anyway, right?

You are not logged in.

#1 2016-08-23 03:44:41, last edited by SirJosh3917 (2016-08-23 03:45:41)

SirJosh3917
Formerly ninjasupeatsninja
From: USA
Joined: 2015-04-05
Posts: 2,095

Signifigant improvements of message loss when using a message query

Whipped up this message query, careful as baking a cake

(github link soon)

using PlayerIOClient;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Yonom.EE;

namespace Bot
{
	public class MessageQuery
	{
		private Connection con;
		private Dictionary<string, Action> MessagesCanRecieve = new Dictionary<string, Action>();
		private List<Message> Recmessages = new List<Message>();
		private List<Message> Senmessages = new List<Message>();
		private bool swork = false;
		private bool rwork = false;
		private bool Initiated = false;

		public void Initiate(Connection conn)
		{
			con = conn;
			Initiated = true;
		}

		public bool CanAddRecieve(Message e)
		{
			if(MessagesCanRecieve.Keys.Contains(e.Type))
				return true;
			return false;
		}

		public void AddCanRecieve(string MessageType, Action Method)
		{
			MessagesCanRecieve.Add(MessageType, Method);
		}

		public bool RWorking()
		{
			return rwork;
		}

		public bool SWorking()
		{
			return swork;
		}

		public void AddRecieveMessage(Message e)
		{
		redo:
			if (!RWorking())
			{
				if (CanAddRecieve(e))
				{
					Recmessages.Add(e);
				}
			}
			else
			{
				while (RWorking())
				{
					// do nothing
					Thread.Sleep(100);
				}
				goto redo;
			}
		}

		public void AddSendMessage(Message e)
		{
			redo:
			if (!SWorking())
			{
				Senmessages.Add(e);
			}
			else
			{
				while(SWorking())
				{
					// do nothing
					Thread.Sleep(100);
				}
				goto redo;
			}
		}

		public bool QueryHasRecieveWork()
		{
			return Recmessages.Count > 0;
		}

		public bool QueryHasSendWork()
		{
			return Senmessages.Count > 0;
		}

		public void FufillSendQuery()
		{
			if (!Initiated) { return; }
			if (!QueryHasSendWork()) { return; }

			swork = true;

			for (int a = 0; a < Senmessages.Count; a++)
			{
				Message e = Senmessages[a];
				PointTo.con.Send(e);
				Thread.Sleep(10);
			}

			Senmessages.Clear();
			swork = false;
		}

		public void FufillRecieveQuery()
		{
			bool nil;

			if (!QueryHasRecieveWork()) { return; }
			rwork = true;

			for (int a = 0; a < Recmessages.Count; a++)
			{
				Message e = Recmessages[a];

				if(MessagesCanRecieve.ContainsKey(e.Type))
					MessagesCanRecieve[e.Type]();

			}

			Recmessages.Clear();

			rwork = false;
		}
	}
}

How 2 use:

1) Define a MessageQuery (q) somewhere

2) Use this code to initiate workers

			q = new MessageQuery();
			new Thread(delegate()
			{
				while (true)
				{
					if (q.QueryHasRecieveWork())
						q.FufillRecieveQuery();
				}
			}).Start();
			new Thread(delegate()
			{
				while (true)
				{
					if (q.QueryHasSendWork())
						q.FufillSendQuery();
				}
			}).Start();

3) Make sure to use some new code snippits

Recieving Messages

4) Add something to send

q.AddSendMessage(Message.Create("say", "your message junk here"));

Something I found out (that's been discovered many times probebly).

This is just my code, you can make your own if it suits you better.

Eh, it's less message loss, meaning more chance of placing all of those blocks.

Offline

#2 2016-08-23 07:35:19, last edited by XxAtillaxX (2016-08-23 07:37:44)

XxAtillaxX
Member
Joined: 2015-11-28
Posts: 4,202

Re: Signifigant improvements of message loss when using a message query

Uh... what? I don't see how this would prevent 'message loss' nor what a 'message query' is.


signature.png
*u stinky*

Offline

Wooted by:

#3 2016-08-23 11:12:46

realmaster42
Formerly marcoantonimsantos
From: ̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍
Joined: 2015-02-20
Posts: 1,380
Website

Re: Signifigant improvements of message loss when using a message query

ugh
you stole my idea/code from R42Bot++, and now you make it even worse
pl0x its much more simple than that

@Atilla MESSAGE LOSS means that you send it too fast and lose a sent message (doesnt send)
and MESSAGE QUERY is a list that stores query, where a timer reads the last item, sends, and destroys last item
pl0x


http://i.imgur.com/bjvgH5L.png?1

Offline

#4 2016-08-23 13:28:53

hummerz5
Member
From: wait I'm not a secret mod huh
Joined: 2015-08-10
Posts: 5,852

Re: Signifigant improvements of message loss when using a message query

yeah it sounds like what marco said, but since it stays on two threads the whole time, you're just as well off writing Thread.Sleep(20) after everything you send.
I like the receiving handler thing like what EE code has, and what I did once (idk why) but that doesn't achieve much anyhow

Offline

#5 2016-08-23 16:05:16

SirJosh3917
Formerly ninjasupeatsninja
From: USA
Joined: 2015-04-05
Posts: 2,095

Re: Signifigant improvements of message loss when using a message query

marcoantonimsantos wrote:

ugh
you stole my idea/code from R42Bot++, and now you make it even worse
pl0x its much more simple than that

@Atilla MESSAGE LOSS means that you send it too fast and lose a sent message (doesnt send)
and MESSAGE QUERY is a list that stores query, where a timer reads the last item, sends, and destroys last item
pl0x

I didn't steal anything, nor would I bother going through the trouble of decompiling and then translating your (possibly messy) code.
Got the idea from spinastar when he said he uses a query.

Offline

#6 2016-08-23 16:11:08

Different55
Forum Admin
Joined: 2015-02-07
Posts: 16,574

Re: Signifigant improvements of message loss when using a message query

Small note: it's called a queue not a query.


"Sometimes failing a leap of faith is better than inching forward"
- ShinsukeIto

Offline

#7 2016-08-23 16:19:09

realmaster42
Formerly marcoantonimsantos
From: ̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍
Joined: 2015-02-20
Posts: 1,380
Website

Re: Signifigant improvements of message loss when using a message query

ninjasupeatsninja wrote:
marcoantonimsantos wrote:

ugh
you stole my idea/code from R42Bot++, and now you make it even worse
pl0x its much more simple than that

@Atilla MESSAGE LOSS means that you send it too fast and lose a sent message (doesnt send)
and MESSAGE QUERY is a list that stores query, where a timer reads the last item, sends, and destroys last item
pl0x

I didn't steal anything, nor would I bother going through the trouble of decompiling and then translating your (possibly messy) code.
Got the idea from spinastar when he said he uses a query.

You could credit him first
also R42Bot++ is open-source in case you don't know
so...

You basically did what I did but even worse with much more unneeded lines.

Different55 wrote:

Small note: it's called a queue not a query.

In this case it is a queue, but queries do exist (messy)


http://i.imgur.com/bjvgH5L.png?1

Offline

#8 2016-08-23 16:48:07

capasha
Member
Joined: 2015-02-21
Posts: 4,066

Re: Signifigant improvements of message loss when using a message query

marcoantonimsantos wrote:
ninjasupeatsninja wrote:
marcoantonimsantos wrote:

ugh
you stole my idea/code from R42Bot++, and now you make it even worse
pl0x its much more simple than that

@Atilla MESSAGE LOSS means that you send it too fast and lose a sent message (doesnt send)
and MESSAGE QUERY is a list that stores query, where a timer reads the last item, sends, and destroys last item
pl0x

I didn't steal anything, nor would I bother going through the trouble of decompiling and then translating your (possibly messy) code.
Got the idea from spinastar when he said he uses a query.

You could credit him first
also R42Bot++ is open-source in case you don't know
so...

You basically did what I did but even worse with much more unneeded lines.

Can you please stop with copyright from your bot. How much haven't you taking code from others?
I don't really care if other people take ideas from my bots. Or making them different.
Seems like you are the only person in this forum page  that getting butthurt every time.

Offline

#9 2016-08-23 16:52:16

Processor
Member
Joined: 2015-02-15
Posts: 2,246

Re: Signifigant improvements of message loss when using a message query

Alright guys. @marco, copyright infringement is against the rules. So. Instead of minimodding, send a DCMA request to Diff and we will have it removed.

@capasha: Copyright is a serious concept and there is no way you can justify copying others without their agreement. Just because you are fine with people using your code doesn't mean everyone else is.

Please no longer post about copyright issues in this thread as it is off-topic.


I have never thought of programming for reputation and honor. What I have in my heart must come out. That is the reason why I code.

Offline

#10 2016-08-24 00:29:37

Tomahawk
Forum Mod
From: UK
Joined: 2015-02-18
Posts: 2,835

Re: Signifigant improvements of message loss when using a message query

There's no received message loss, and you don't need a 10ms delay between every packet you send, even for blocks.

Seems unnecessarily complex.


One bot to rule them all, one bot to find them. One bot to bring them all... and with this cliché blind them.

Offline

Wooted by: (2)

#11 2016-08-25 12:38:18

realmaster42
Formerly marcoantonimsantos
From: ̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍
Joined: 2015-02-20
Posts: 1,380
Website

Re: Signifigant improvements of message loss when using a message query

Tomahawk wrote:

There's no received message loss, and you don't need a 10ms delay between every packet you send, even for blocks.

Seems unnecessarily complex.

^

This would only be good if you want the bot to say something, in wich that case multiple runs at somewhat same time could lose send.


http://i.imgur.com/bjvgH5L.png?1

Offline

#12 2016-08-25 13:58:00

Hexagon
Member
Joined: 2015-04-22
Posts: 1,213

Re: Signifigant improvements of message loss when using a message query

Do you have any quantitative data that shows that this program would offer an improvement over the protocol now?

Offline

#13 2016-08-25 14:02:47

SirJosh3917
Formerly ninjasupeatsninja
From: USA
Joined: 2015-04-05
Posts: 2,095

Re: Signifigant improvements of message loss when using a message query

honestly this is just something i thought worked and noticed, it seems to work so *shrug*

honestly i think by now it's only i who think this works
*shrug* closing topic *shrug*

Offline

Wooted by:
SirJosh39171472130167620668

Board footer

Powered by FluxBB

[ Started around 1714006672.5426 - Generated in 0.163 seconds, 12 queries executed - Memory usage: 1.58 MiB (Peak: 1.78 MiB) ]